mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-02-17 00:21:20 -05:00
use initialState to set, reset state of join-flow component
This commit is contained in:
parent
3469f17bfe
commit
eeb9f03887
1 changed files with 3 additions and 9 deletions
|
@ -29,13 +29,14 @@ class JoinFlow extends React.Component {
|
|||
'handleRegistrationResponse',
|
||||
'handleSubmitRegistration'
|
||||
]);
|
||||
this.state = {
|
||||
this.initialState = {
|
||||
numAttempts: 0,
|
||||
formData: {},
|
||||
registrationError: null,
|
||||
step: 0,
|
||||
waiting: false
|
||||
};
|
||||
this.state = this.initialState;
|
||||
}
|
||||
canTryAgain () {
|
||||
return (this.state.numAttempts <= 1);
|
||||
|
@ -152,14 +153,7 @@ class JoinFlow extends React.Component {
|
|||
}
|
||||
}
|
||||
resetState () {
|
||||
// TODO: refactor this to have initial state live in one place only
|
||||
this.setState({
|
||||
numAttempts: 0,
|
||||
formData: {},
|
||||
registrationError: null,
|
||||
step: 0,
|
||||
waiting: false
|
||||
});
|
||||
this.setState(this.initialState);
|
||||
}
|
||||
render () {
|
||||
return (
|
||||
|
|
Loading…
Reference in a new issue