|
|
@@ -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);
|