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
+25 -12
View File
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
// import PropTypes from 'prop-types';
import Wikipedia from './Wikipedia';
import Wikipedia from './areainfo/Wikipedia';
import { Col, Tabs, Tab } from 'react-bootstrap';
import axios from 'axios';
@@ -10,20 +10,26 @@ class VideoInfo extends Component {
this.state={
error: null,
isLoaded: false,
VideoDetails: {}
VideoDetails: {},
videoId: '0J2QdDbelmY'
};
}
// componentWillMount() {
// }
componentWillMount() {
if(this.props.match.params.id){
if(this.props.match.params.id === this.state.videoId){}
else{
this.setState({videoId: this.props.match.params.id});
}
}
}
componentDidMount() {
axios.get('https://www.googleapis.com/youtube/v3/videos', {
params: {
'part': 'snippet,contentDetails,statistics,topicDetails',
'id': this.props.match.params.id,
'id': this.state.videoId,
'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig'
}
}).then(response => {
@@ -47,13 +53,20 @@ class VideoInfo extends Component {
// }
// componentWillUpdate(nextProps, nextState) {
componentWillUpdate(nextProps, nextState) {
// console.info('nextProps',nextProps);
// console.info('nextState',nextState);
if(nextProps.match.params.id === this.state.videoId){}
else{
this.setState({videoId: nextProps.match.params.id});
}
}
// }
// componentDidUpdate(prevProps, prevState) {
// }
componentDidUpdate(prevProps, prevState) {
console.info('prevProps',prevProps);
console.info('prevState',prevState);
}
// componentWillUnmount() {