riorganizzazione files, gestione id videoplayer e videoinfo

This commit is contained in:
matteo
2018-11-24 01:41:45 +01:00
parent d33876d1e7
commit bb71bf270c
12 changed files with 122 additions and 80 deletions
-87
View File
@@ -1,87 +0,0 @@
import React, { Component } from 'react';
// import PropTypes from 'prop-types';
import wikijs from 'wikijs';
class Wikipedia extends Component {
constructor(props) {
super(props);
this.state = {
data: {},
infobox: {},
error: null,
isLoaded: false
};
this.getWikiBox = this.getWikiBox.bind(this);
}
getWikiBox(name){
wikijs()
.page(name)
.then(page => page.fullInfo())
.then(infobox => console.log(infobox)
//this.setState({ infobox })
);
//console.log('infobox', this.state.infobox)
}
// componentWillMount() {
// }
componentDidMount() {
wikijs().search(this.props.query).then(data => {
this.setState({
data,
isLoaded: true
});
console.log(data);
}, error => {
console.error(error);
this.setState({
isLoaded: true,
error
});
});
}
// componentWillReceiveProps(nextProps) {
// }
// shouldComponentUpdate(nextProps, nextState) {
// }
// componentWillUpdate(nextProps, nextState) {
// }
// componentDidUpdate(prevProps, prevState) {
// }
// componentWillUnmount() {
// }
render() {
const { data, error, isLoaded } = this.state;
if (error) {
return (
<React.Fragment>
Error: {error.message} -- Cannot get {error.config.url}
</React.Fragment>
);
} else if (!isLoaded) {
return <React.Fragment>Loading...</React.Fragment>;
} else {
return (
<div>
<p>risultato ricerca wikipedia: { data.results[0] }</p>
</div>
);
}
}
}
export default Wikipedia;