prevent setState after submitting the form

This commit is contained in:
Mikhail Mikheev 2019-04-24 19:26:35 +04:00
parent 2e8b3543b0
commit 749a6bd4f6
1 changed files with 8 additions and 1 deletions

View File

@ -78,8 +78,14 @@ const AddCustomToken = (props: Props) => {
const formSpyOnChangeHandler = async (state) => {
const {
errors, validating, values, dirty,
errors, validating, values, dirty, submitSucceeded,
} = state
// for some reason this is called after submitting, we don't need to update the values
// after submit
if (submitSucceeded) {
return
}
if (dirty && !validating && errors.address) {
setFormValues(INITIAL_FORM_STATE)
}
@ -122,6 +128,7 @@ const AddCustomToken = (props: Props) => {
errors: true,
validating: true,
dirty: true,
submitSucceeded: true,
}}
onChange={formSpyOnChangeHandler}
/>