Przeglądaj źródła

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 lat temu
rodzic
commit
822bc31d69

+ 2
- 46
react/features/base/media/components/AbstractVideoTrack.js Wyświetl plik

@@ -47,24 +47,13 @@ export type Props = {
47 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 51
  * Implements a React {@link Component} that renders video element for a
63 52
  * specific video track.
64 53
  *
65 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 58
      * Initializes a new AbstractVideoTrack instance.
70 59
      *
@@ -74,31 +63,10 @@ export default class AbstractVideoTrack<P: Props> extends Component<P, State> {
74 63
     constructor(props: P) {
75 64
         super(props);
76 65
 
77
-        this.state = {
78
-            videoTrack: _falsy2null(props.videoTrack)
79
-        };
80
-
81 66
         // Bind event handlers so they are only bound once for every instance.
82 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 71
      * Implements React's {@link Component#render()}.
104 72
      *
@@ -106,7 +74,7 @@ export default class AbstractVideoTrack<P: Props> extends Component<P, State> {
106 74
      * @returns {ReactElement}
107 75
      */
108 76
     render() {
109
-        const { videoTrack } = this.state;
77
+        const videoTrack = _falsy2null(this.props.videoTrack);
110 78
         let render;
111 79
 
112 80
         if (this.props.waitForVideoStarted && videoTrack) {
@@ -168,18 +136,6 @@ export default class AbstractVideoTrack<P: Props> extends Component<P, State> {
168 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
 /**

Ładowanie…
Anuluj
Zapisz