Browse Source

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.
master
Leonard Kim 7 years ago
parent
commit
822bc31d69
1 changed files with 2 additions and 46 deletions
  1. 2
    46
      react/features/base/media/components/AbstractVideoTrack.js

+ 2
- 46
react/features/base/media/components/AbstractVideoTrack.js View File

47
     zoomEnabled?: boolean
47
     zoomEnabled?: boolean
48
 };
48
 };
49
 
49
 
50
-/**
51
- * The type of the React {@code Component} state of {@link AbstractVideoTrack}.
52
- */
53
-type State = {
54
-
55
-    /**
56
-     * The Redux representation of the participant's video track.
57
-     */
58
-    videoTrack: Object | null
59
-};
60
-
61
 /**
50
 /**
62
  * Implements a React {@link Component} that renders video element for a
51
  * Implements a React {@link Component} that renders video element for a
63
  * specific video track.
52
  * specific video track.
64
  *
53
  *
65
  * @abstract
54
  * @abstract
66
  */
55
  */
67
-export default class AbstractVideoTrack<P: Props> extends Component<P, State> {
56
+export default class AbstractVideoTrack<P: Props> extends Component<P> {
68
     /**
57
     /**
69
      * Initializes a new AbstractVideoTrack instance.
58
      * Initializes a new AbstractVideoTrack instance.
70
      *
59
      *
74
     constructor(props: P) {
63
     constructor(props: P) {
75
         super(props);
64
         super(props);
76
 
65
 
77
-        this.state = {
78
-            videoTrack: _falsy2null(props.videoTrack)
79
-        };
80
-
81
         // Bind event handlers so they are only bound once for every instance.
66
         // Bind event handlers so they are only bound once for every instance.
82
         this._onVideoPlaying = this._onVideoPlaying.bind(this);
67
         this._onVideoPlaying = this._onVideoPlaying.bind(this);
83
     }
68
     }
84
 
69
 
85
-    /**
86
-     * Implements React's {@link Component#componentWillReceiveProps()}.
87
-     *
88
-     * @inheritdoc
89
-     * @param {Object} nextProps - The read-only props which this Component will
90
-     * receive.
91
-     * @returns {void}
92
-     */
93
-    componentWillReceiveProps(nextProps: P) {
94
-        const oldValue = this.state.videoTrack;
95
-        const newValue = _falsy2null(nextProps.videoTrack);
96
-
97
-        if (oldValue !== newValue) {
98
-            this._setVideoTrack(newValue);
99
-        }
100
-    }
101
-
102
     /**
70
     /**
103
      * Implements React's {@link Component#render()}.
71
      * Implements React's {@link Component#render()}.
104
      *
72
      *
106
      * @returns {ReactElement}
74
      * @returns {ReactElement}
107
      */
75
      */
108
     render() {
76
     render() {
109
-        const { videoTrack } = this.state;
77
+        const videoTrack = _falsy2null(this.props.videoTrack);
110
         let render;
78
         let render;
111
 
79
 
112
         if (this.props.waitForVideoStarted && videoTrack) {
80
         if (this.props.waitForVideoStarted && videoTrack) {
168
             this.props.dispatch(trackVideoStarted(videoTrack.jitsiTrack));
136
             this.props.dispatch(trackVideoStarted(videoTrack.jitsiTrack));
169
         }
137
         }
170
     }
138
     }
171
-
172
-    /**
173
-     * Sets a specific video track to be rendered by this instance.
174
-     *
175
-     * @param {Track} videoTrack - The video track to be rendered by this
176
-     * instance.
177
-     * @protected
178
-     * @returns {void}
179
-     */
180
-    _setVideoTrack(videoTrack) {
181
-        this.setState({ videoTrack });
182
-    }
183
 }
139
 }
184
 
140
 
185
 /**
141
 /**

Loading…
Cancel
Save