Przeglądaj źródła

ref(labels): use getDerivedStateFromProps to get display state

master
Leonard Kim 7 lat temu
rodzic
commit
b24e7ec5f0
1 zmienionych plików z 13 dodań i 16 usunięć
  1. 13
    16
      react/features/large-video/components/Labels.web.js

+ 13
- 16
react/features/large-video/components/Labels.web.js Wyświetl plik

@@ -32,6 +32,19 @@ type State = {
32 32
  * @extends Component
33 33
  */
34 34
 class Labels extends AbstractLabels<Props, State> {
35
+    /**
36
+     * Updates the state for whether or not the filmstrip is transitioning to
37
+     * a displayed state.
38
+     *
39
+     * @inheritdoc
40
+     */
41
+    static getDerivedStateFromProps(props, prevState) {
42
+        return {
43
+            filmstripBecomingVisible: !prevState.filmstripBecomingVisible
44
+                && props._filmstripVisible
45
+        };
46
+    }
47
+
35 48
     /**
36 49
      * Initializes a new {@code Labels} instance.
37 50
      *
@@ -46,22 +59,6 @@ class Labels extends AbstractLabels<Props, State> {
46 59
         };
47 60
     }
48 61
 
49
-    /**
50
-     * Updates the state for whether or not the filmstrip is being toggled to
51
-     * display after having being hidden.
52
-     *
53
-     * @inheritdoc
54
-     * @param {Object} nextProps - The read-only props which this Component will
55
-     * receive.
56
-     * @returns {void}
57
-     */
58
-    componentWillReceiveProps(nextProps) {
59
-        this.setState({
60
-            filmstripBecomingVisible: nextProps._filmstripVisible
61
-                && !this.props._filmstripVisible
62
-        });
63
-    }
64
-
65 62
     /**
66 63
      * Implements React's {@link Component#render()}.
67 64
      *

Ładowanie…
Anuluj
Zapisz