fix: register page crashing after click on field "username" (#1027)

This commit is contained in:
Dmytro
2023-08-24 08:57:14 +03:00
committed by GitHub
parent 1cca916784
commit 728154a577

View File

@@ -131,10 +131,20 @@ class RegistrationPage extends React.Component {
// Exemption for country field's value as we need to set updated value from the store.
if (focusedField === 'country') { focusedField = ''; }
const { [focusedField]: _, ...registrationData } = { ...nextProps.registrationFormData, ...nextState };
this.setState({
...registrationData,
});
// For username field's value as we need to wait for usernameSuggestions.
// Otherwise, an infinite state update loop error appears.
if (focusedField === 'username') {
this.setState({
...nextProps.registrationFormData,
...nextState,
});
} else {
const { [focusedField]: _, ...registrationData } = { ...nextProps.registrationFormData, ...nextState };
this.setState({
...registrationData,
});
}
}
if (this.props.usernameSuggestions.length > 0 && this.state.username === '') {