Просмотр исходного кода

ref(recording-label): derive when the label state is no longer stale

master
Leonard Kim 7 лет назад
Родитель
Сommit
d4e18e78fa
1 измененных файлов: 15 добавлений и 8 удалений
  1. 15
    8
      react/features/recording/components/AbstractRecordingLabel.js

+ 15
- 8
react/features/recording/components/AbstractRecordingLabel.js Просмотреть файл

54
  */
54
  */
55
 export default class AbstractRecordingLabel
55
 export default class AbstractRecordingLabel
56
     extends Component<Props, State> {
56
     extends Component<Props, State> {
57
+    /**
58
+     * Implements {@code Component#getDerivedStateFromProps}.
59
+     *
60
+     * @inheritdoc
61
+     */
62
+    static getDerivedStateFromProps(props: Props, prevState: State) {
63
+        return {
64
+            staleLabel: props._status !== JitsiRecordingConstants.status.OFF
65
+                && prevState.staleLabel ? false : prevState.staleLabel
66
+        };
67
+    }
68
+
57
     /**
69
     /**
58
      * Initializes a new {@code AbstractRecordingLabel} component.
70
      * Initializes a new {@code AbstractRecordingLabel} component.
59
      *
71
      *
70
     }
82
     }
71
 
83
 
72
     /**
84
     /**
73
-     * Implements {@code Component#componentWillReceiveProps}.
85
+     * Implements {@code Component#componentDidUpdate}.
74
      *
86
      *
75
      * @inheritdoc
87
      * @inheritdoc
76
      */
88
      */
77
-    componentWillReceiveProps(newProps: Props) {
78
-        this._updateStaleStatus(this.props, newProps);
89
+    componentDidUpdate(prevProps: Props) {
90
+        this._updateStaleStatus(prevProps, this.props);
79
     }
91
     }
80
 
92
 
81
     /**
93
     /**
137
                     }
149
                     }
138
                 }, STALE_TIMEOUT);
150
                 }, STALE_TIMEOUT);
139
             }
151
             }
140
-        } else if (this.state.staleLabel) {
141
-            this.setState({
142
-                staleLabel: false
143
-            });
144
         }
152
         }
145
     }
153
     }
146
-
147
 }
154
 }
148
 
155
 
149
 /**
156
 /**

Загрузка…
Отмена
Сохранить