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
+20 -2
View File
@@ -20,7 +20,8 @@ class ValidationView extends React.PureComponent {
super(props);
this.state = {
code: props.credCode || ''
code: props.credCode || '',
codeReceived: false
};
this.handleChange = this.handleChange.bind(this);
@@ -29,6 +30,24 @@ class ValidationView extends React.PureComponent {
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) {
// Submit code audomatically if it's received from the parent.
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});
}
@@ -53,7 +72,6 @@ class ValidationView extends React.PureComponent {
this.props.onCancel();
}
render() {
const { formatMessage } = this.props.intl;
const methods = {'email': formatMessage(messages.email), 'tel': formatMessage(messages.phone)};
+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
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long