diff options
author | Whymarrh Whitby <whymarrh.whitby@gmail.com> | 2018-07-06 00:29:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-06 00:29:46 +0800 |
commit | 60857f94ad7a91a8169d717c08971622657cc6c4 (patch) | |
tree | d6790227077b5637c303c4be0e8ff8fcc2f1e246 /ui | |
parent | e59e92e028d3c133a15522304b172e326af1ee6b (diff) | |
parent | 783559f94ef7370d2fef88327c500fbe826ac0b0 (diff) | |
download | tangerine-wallet-browser-60857f94ad7a91a8169d717c08971622657cc6c4.tar tangerine-wallet-browser-60857f94ad7a91a8169d717c08971622657cc6c4.tar.gz tangerine-wallet-browser-60857f94ad7a91a8169d717c08971622657cc6c4.tar.bz2 tangerine-wallet-browser-60857f94ad7a91a8169d717c08971622657cc6c4.tar.lz tangerine-wallet-browser-60857f94ad7a91a8169d717c08971622657cc6c4.tar.xz tangerine-wallet-browser-60857f94ad7a91a8169d717c08971622657cc6c4.tar.zst tangerine-wallet-browser-60857f94ad7a91a8169d717c08971622657cc6c4.zip |
Merge pull request #4733 from whymarrh/fix-setstate-warnings
Fix setState warnings in components using TokenTracker
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/components/token-balance.js | 6 | ||||
-rw-r--r-- | ui/app/components/token-list.js | 5 | ||||
-rw-r--r-- | ui/app/helpers/with-token-tracker.js | 3 |
3 files changed, 14 insertions, 0 deletions
diff --git a/ui/app/components/token-balance.js b/ui/app/components/token-balance.js index df3bd59bb..99ca7335c 100644 --- a/ui/app/components/token-balance.js +++ b/ui/app/components/token-balance.js @@ -98,6 +98,10 @@ TokenBalance.prototype.componentDidUpdate = function (nextProps) { } TokenBalance.prototype.updateBalance = function (tokens = []) { + if (!this.tracker.running) { + return + } + const [{ string, symbol }] = tokens this.setState({ @@ -110,5 +114,7 @@ TokenBalance.prototype.updateBalance = function (tokens = []) { TokenBalance.prototype.componentWillUnmount = function () { if (!this.tracker) return this.tracker.stop() + this.tracker.removeListener('update', this.balanceUpdater) + this.tracker.removeListener('error', this.showError) } diff --git a/ui/app/components/token-list.js b/ui/app/components/token-list.js index 4189cf801..42351cf89 100644 --- a/ui/app/components/token-list.js +++ b/ui/app/components/token-list.js @@ -158,12 +158,17 @@ TokenList.prototype.componentDidUpdate = function (nextProps) { } TokenList.prototype.updateBalances = function (tokens) { + if (!this.tracker.running) { + return + } this.setState({ tokens, isLoading: false }) } TokenList.prototype.componentWillUnmount = function () { if (!this.tracker) return this.tracker.stop() + this.tracker.removeListener('update', this.balanceUpdater) + this.tracker.removeListener('error', this.showError) } // function uniqueMergeTokens (tokensA, tokensB = []) { diff --git a/ui/app/helpers/with-token-tracker.js b/ui/app/helpers/with-token-tracker.js index e24517c18..8608b15f4 100644 --- a/ui/app/helpers/with-token-tracker.js +++ b/ui/app/helpers/with-token-tracker.js @@ -75,6 +75,9 @@ const withTokenTracker = WrappedComponent => { } updateBalance (tokens = []) { + if (!this.tracker.running) { + return + } const [{ string, symbol }] = tokens this.setState({ string, symbol, error: null }) } |