浏览代码

fix: Fixes syncing state about lobby in security dialog.

j8
damencho 5 年前
父节点
当前提交
b9c20a3fd4
共有 1 个文件被更改,包括 9 次插入8 次删除
  1. 9
    8
      react/features/lobby/components/web/LobbySection.js

+ 9
- 8
react/features/lobby/components/web/LobbySection.js 查看文件

@@ -59,18 +59,19 @@ class LobbySection extends PureComponent<Props, State> {
59 59
     }
60 60
 
61 61
     /**
62
-     * Implements {@code PureComponent#componentDidUpdate}.
62
+     * Implements React's {@link Component#getDerivedStateFromProps()}.
63 63
      *
64 64
      * @inheritdoc
65 65
      */
66
-    componentDidUpdate(prevProps, prevState) {
67
-        if (this.props._lobbyEnabled !== prevProps._lobbyEnabled
68
-                && this.state.lobbyEnabled !== prevState.lobbyEnabled) {
69
-            // eslint-disable-next-line react/no-did-update-set-state
70
-            this.setState({
71
-                lobbyEnabled: this.props._lobbyEnabled
72
-            });
66
+    static getDerivedStateFromProps(props: Props, state: Object) {
67
+        if (props._lobbyEnabled !== state.lobbyEnabled) {
68
+
69
+            return {
70
+                lobbyEnabled: props._lobbyEnabled
71
+            };
73 72
         }
73
+
74
+        return null;
74 75
     }
75 76
 
76 77
     /**

正在加载...
取消
保存