partial fix for #100

This commit is contained in:
or-else
2022-08-25 13:03:31 -10:00
parent 8b80f59d3a
commit 740cb7faf8
5 changed files with 42 additions and 6 deletions
+19 -1
View File
@@ -9789,7 +9789,8 @@ class ValidationView extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureC
constructor(props) {
super(props);
this.state = {
code: props.credCode || ''
code: props.credCode || '',
codeReceived: false
};
this.handleChange = this.handleChange.bind(this);
this.handleKeyPress = this.handleKeyPress.bind(this);
@@ -9797,6 +9798,23 @@ class ValidationView extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureC
this.handleCancel = this.handleCancel.bind(this);
}
static getDerivedStateFromProps(nextProps, prevState) {
if (nextProps.credCode != prevState.code) {
return {
code: nextProps.credCode || '',
codeReceived: !!nextProps.credCode
};
}
return prevState;
}
componentDidUpdate(prevProps, prevState) {
if (this.state.codeReceived && this.state.code != prevState.code) {
this.props.onSubmit(this.props.credMethod, this.state.code.trim());
}
}
handleChange(e) {
this.setState({
code: e.target.value