浏览代码

ref(info): derive when to clear the entered password state

master
Leonard Kim 7 年前
父节点
当前提交
e0cbb838be
共有 1 个文件被更改,包括 11 次插入14 次删除
  1. 11
    14
      react/features/invite/components/info-dialog/PasswordForm.web.js

+ 11
- 14
react/features/invite/components/info-dialog/PasswordForm.web.js 查看文件

@@ -55,6 +55,17 @@ type State = {
55 55
  * @extends Component
56 56
  */
57 57
 class PasswordForm extends Component<Props, State> {
58
+    /**
59
+     * Implements React's {@link Component#getDerivedStateFromProps()}.
60
+     *
61
+     * @inheritdoc
62
+     */
63
+    static getDerivedStateFromProps(props, state) {
64
+        return {
65
+            enteredPassword: props.editEnabled ? state.enteredPassword : ''
66
+        };
67
+    }
68
+
58 69
     state = {
59 70
         enteredPassword: ''
60 71
     };
@@ -74,19 +85,6 @@ class PasswordForm extends Component<Props, State> {
74 85
         this._onPasswordSubmit = this._onPasswordSubmit.bind(this);
75 86
     }
76 87
 
77
-    /**
78
-     * Implements React's {@link Component#componentWillReceiveProps()}. Invoked
79
-     * before this mounted component receives new props.
80
-     *
81
-     * @inheritdoc
82
-     * @param {Props} nextProps - New props component will receive.
83
-     */
84
-    componentWillReceiveProps(nextProps: Props) {
85
-        if (this.props.editEnabled && !nextProps.editEnabled) {
86
-            this.setState({ enteredPassword: '' });
87
-        }
88
-    }
89
-
90 88
     /**
91 89
      * Implements React's {@link Component#render()}.
92 90
      *
@@ -182,5 +180,4 @@ class PasswordForm extends Component<Props, State> {
182 180
     }
183 181
 }
184 182
 
185
-
186 183
 export default translate(PasswordForm);

正在加载...
取消
保存