From 749a6bd4f6b33c3e5c5a5d1a584f3fb7749a70df Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Wed, 24 Apr 2019 19:26:35 +0400 Subject: [PATCH] prevent setState after submitting the form --- .../Balances/Tokens/screens/AddCustomToken/index.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/routes/safe/components/Balances/Tokens/screens/AddCustomToken/index.jsx b/src/routes/safe/components/Balances/Tokens/screens/AddCustomToken/index.jsx index 9d99bd9a..bd256389 100644 --- a/src/routes/safe/components/Balances/Tokens/screens/AddCustomToken/index.jsx +++ b/src/routes/safe/components/Balances/Tokens/screens/AddCustomToken/index.jsx @@ -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} />