From 822bc31d69dfad29a45875e36a5b400504c90553 Mon Sep 17 00:00:00 2001 From: Leonard Kim Date: Sat, 1 Dec 2018 11:50:33 -0800 Subject: [PATCH] ref(video): use videoTrack from props It doesn't seem like videoTrack needs to be set onto state if it can be accessed directly from props. Removing the state automatically removes the deprecated componentWillReceiveProps. --- .../media/components/AbstractVideoTrack.js | 48 +------------------ 1 file changed, 2 insertions(+), 46 deletions(-) diff --git a/react/features/base/media/components/AbstractVideoTrack.js b/react/features/base/media/components/AbstractVideoTrack.js index 4b5fda9cd..557ff933b 100644 --- a/react/features/base/media/components/AbstractVideoTrack.js +++ b/react/features/base/media/components/AbstractVideoTrack.js @@ -47,24 +47,13 @@ export type Props = { zoomEnabled?: boolean }; -/** - * The type of the React {@code Component} state of {@link AbstractVideoTrack}. - */ -type State = { - - /** - * The Redux representation of the participant's video track. - */ - videoTrack: Object | null -}; - /** * Implements a React {@link Component} that renders video element for a * specific video track. * * @abstract */ -export default class AbstractVideoTrack extends Component { +export default class AbstractVideoTrack extends Component

{ /** * Initializes a new AbstractVideoTrack instance. * @@ -74,31 +63,10 @@ export default class AbstractVideoTrack extends Component { constructor(props: P) { super(props); - this.state = { - videoTrack: _falsy2null(props.videoTrack) - }; - // Bind event handlers so they are only bound once for every instance. this._onVideoPlaying = this._onVideoPlaying.bind(this); } - /** - * Implements React's {@link Component#componentWillReceiveProps()}. - * - * @inheritdoc - * @param {Object} nextProps - The read-only props which this Component will - * receive. - * @returns {void} - */ - componentWillReceiveProps(nextProps: P) { - const oldValue = this.state.videoTrack; - const newValue = _falsy2null(nextProps.videoTrack); - - if (oldValue !== newValue) { - this._setVideoTrack(newValue); - } - } - /** * Implements React's {@link Component#render()}. * @@ -106,7 +74,7 @@ export default class AbstractVideoTrack extends Component { * @returns {ReactElement} */ render() { - const { videoTrack } = this.state; + const videoTrack = _falsy2null(this.props.videoTrack); let render; if (this.props.waitForVideoStarted && videoTrack) { @@ -168,18 +136,6 @@ export default class AbstractVideoTrack extends Component { this.props.dispatch(trackVideoStarted(videoTrack.jitsiTrack)); } } - - /** - * Sets a specific video track to be rendered by this instance. - * - * @param {Track} videoTrack - The video track to be rendered by this - * instance. - * @protected - * @returns {void} - */ - _setVideoTrack(videoTrack) { - this.setState({ videoTrack }); - } } /**