Browse Source

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

master
Leonard Kim 7 years ago
parent
commit
e0cbb838be
1 changed files with 11 additions and 14 deletions
  1. 11
    14
      react/features/invite/components/info-dialog/PasswordForm.web.js

+ 11
- 14
react/features/invite/components/info-dialog/PasswordForm.web.js View File

55
  * @extends Component
55
  * @extends Component
56
  */
56
  */
57
 class PasswordForm extends Component<Props, State> {
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
     state = {
69
     state = {
59
         enteredPassword: ''
70
         enteredPassword: ''
60
     };
71
     };
74
         this._onPasswordSubmit = this._onPasswordSubmit.bind(this);
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
      * Implements React's {@link Component#render()}.
89
      * Implements React's {@link Component#render()}.
92
      *
90
      *
182
     }
180
     }
183
 }
181
 }
184
 
182
 
185
-
186
 export default translate(PasswordForm);
183
 export default translate(PasswordForm);

Loading…
Cancel
Save