import React from 'react'; import { Route, Switch, withRouter, matchPath } from 'react-router-dom'; import { Row, Col, Button, Collapse } from 'react-bootstrap'; import TopBar from './TopBar'; import VideoPlayer from './VideoPlayer'; import VideoInfo from './VideoInfo'; import VideoList from './VideoList'; import Suggestion from './Suggestion'; import { ReactHeight } from 'react-height'; import './css/App.css'; class App extends React.Component { state = { playerHeight: null, navHeight: null, blackbgHeight: null, isInfoToggled: false, videoId: localStorage['lastId'] }; // componentDidMount() { // } // componentDidUpdate(prevProps, prevState) { // } static getDerivedStateFromProps(nextProps, prevState) { let idMatch = matchPath(nextProps.location.pathname, { path: "/video/:id", exact: true, strict: false }); if (idMatch && idMatch.params.id !== prevState.videoId) { localStorage.setItem('lastId', idMatch.params.id) return { videoId: idMatch.params.id }; } return null; } render() { return ( { this.setState({ playerHeight: height }) }}> {/* true = style for xs ;; false = style for lg */}
} />
URL not found
} />
); } } export default withRouter(App);