diff options
author | Fabio Berger <me@fabioberger.com> | 2018-01-31 03:12:32 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-01-31 03:12:32 +0800 |
commit | e219772b2a25712f41fb819be36917d3b889201f (patch) | |
tree | c9720d042e65d896c33d68eed918e69c3ad3771c /packages/website/ts/components/dialogs | |
parent | 144a507a2e0e341e8c8b97f67a25e1283ebc3687 (diff) | |
download | dexon-sol-tools-e219772b2a25712f41fb819be36917d3b889201f.tar dexon-sol-tools-e219772b2a25712f41fb819be36917d3b889201f.tar.gz dexon-sol-tools-e219772b2a25712f41fb819be36917d3b889201f.tar.bz2 dexon-sol-tools-e219772b2a25712f41fb819be36917d3b889201f.tar.lz dexon-sol-tools-e219772b2a25712f41fb819be36917d3b889201f.tar.xz dexon-sol-tools-e219772b2a25712f41fb819be36917d3b889201f.tar.zst dexon-sol-tools-e219772b2a25712f41fb819be36917d3b889201f.zip |
Fix all setState calls after unmounted errors. Decided to create our own flag rather then using a cancellablePromise since there was little to be gained from this alternative
Diffstat (limited to 'packages/website/ts/components/dialogs')
-rw-r--r-- | packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx index a3a39a1b9..acd4a7110 100644 --- a/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx +++ b/packages/website/ts/components/dialogs/eth_weth_conversion_dialog.tsx @@ -33,8 +33,10 @@ export class EthWethConversionDialog extends React.Component< EthWethConversionDialogProps, EthWethConversionDialogState > { + private _isUnmounted: boolean; constructor() { super(); + this._isUnmounted = false; this.state = { shouldShowIncompleteErrs: false, hasErrors: false, @@ -46,6 +48,9 @@ export class EthWethConversionDialog extends React.Component< // tslint:disable-next-line:no-floating-promises this._fetchEthTokenBalanceAsync(); } + public componentWillUnmount() { + this._isUnmounted = true; + } public render() { const convertDialogActions = [ <FlatButton key="cancel" label="Cancel" onTouchTap={this._onCancel.bind(this)} />, @@ -181,9 +186,11 @@ export class EthWethConversionDialog extends React.Component< this.props.userAddress, this.props.token.address, ); - this.setState({ - isEthTokenBalanceLoaded: true, - ethTokenBalance: balance, - }); + if (!this._isUnmounted) { + this.setState({ + isEthTokenBalanceLoaded: true, + ethTokenBalance: balance, + }); + } } } |