瀏覽代碼

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
     }
59
     }
60
 
60
 
61
     /**
61
     /**
62
-     * Implements {@code PureComponent#componentDidUpdate}.
62
+     * Implements React's {@link Component#getDerivedStateFromProps()}.
63
      *
63
      *
64
      * @inheritdoc
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
     /**

Loading…
取消
儲存