From 7229f0f9fcd6c2579c3c5a5146a3b144929b6d2e Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Wed, 21 Nov 2018 15:22:18 -0330 Subject: Fix usage of setState in ConfirmTransactionBase#handleSubmit (#5799) --- .../confirm-transaction-base.component.js | 45 ++++++++++++++-------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'ui/app/components/pages/confirm-transaction-base') diff --git a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js index 0651c676b..e3abde233 100644 --- a/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -295,22 +295,35 @@ export default class ConfirmTransactionBase extends Component { return } - this.setState({ submitting: true, submitError: null }) - - if (onSubmit) { - Promise.resolve(onSubmit(txData)) - .then(this.setState({ submitting: false })) - } else { - sendTransaction(txData) - .then(() => { - clearConfirmTransaction() - this.setState({ submitting: false }) - history.push(DEFAULT_ROUTE) - }) - .catch(error => { - this.setState({ submitting: false, submitError: error.message }) - }) - } + this.setState({ + submitting: true, + submitError: null, + }, () => { + if (onSubmit) { + Promise.resolve(onSubmit(txData)) + .then(() => { + this.setState({ + submitting: false, + }) + }) + } else { + sendTransaction(txData) + .then(() => { + clearConfirmTransaction() + this.setState({ + submitting: false, + }, () => { + history.push(DEFAULT_ROUTE) + }) + }) + .catch(error => { + this.setState({ + submitting: false, + submitError: error.message, + }) + }) + } + }) } renderTitleComponent () { -- cgit v1.2.3