aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components
diff options
context:
space:
mode:
authorWhymarrh Whitby <whymarrh.whitby@gmail.com>2018-07-06 00:29:46 +0800
committerGitHub <noreply@github.com>2018-07-06 00:29:46 +0800
commit60857f94ad7a91a8169d717c08971622657cc6c4 (patch)
treed6790227077b5637c303c4be0e8ff8fcc2f1e246 /ui/app/components
parente59e92e028d3c133a15522304b172e326af1ee6b (diff)
parent783559f94ef7370d2fef88327c500fbe826ac0b0 (diff)
downloadtangerine-wallet-browser-60857f94ad7a91a8169d717c08971622657cc6c4.tar.gz
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/app/components')
-rw-r--r--ui/app/components/token-balance.js6
-rw-r--r--ui/app/components/token-list.js5
2 files changed, 11 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 = []) {