Skip to content

Commit

Permalink
Fix usage of setState in ConfirmTransactionBase#handleSubmit (#5799)
Browse files Browse the repository at this point in the history
  • Loading branch information
whymarrh authored Nov 21, 2018
1 parent 74c18ef commit 7229f0f
Showing 1 changed file with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 7229f0f

Please sign in to comment.