diff options
author | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2018-11-22 02:52:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-22 02:52:18 +0800 |
commit | 7229f0f9fcd6c2579c3c5a5146a3b144929b6d2e (patch) | |
tree | 0a791d664f82671ec8d4452523b9031dcc5e9237 | |
parent | 74c18ef0e81e73873f0b57f3f0cc1afb5a05d8cc (diff) | |
download | tangerine-wallet-browser-7229f0f9fcd6c2579c3c5a5146a3b144929b6d2e.tar.gz tangerine-wallet-browser-7229f0f9fcd6c2579c3c5a5146a3b144929b6d2e.tar.zst tangerine-wallet-browser-7229f0f9fcd6c2579c3c5a5146a3b144929b6d2e.zip |
Fix usage of setState in ConfirmTransactionBase#handleSubmit (#5799)
-rw-r--r-- | ui/app/components/pages/confirm-transaction-base/confirm-transaction-base.component.js | 45 |
1 files changed, 29 insertions, 16 deletions
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 () { |