mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #4733 from whymarrh/fix-setstate-warnings
Fix setState warnings in components using TokenTracker
This commit is contained in:
commit
60857f94ad
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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 = []) {
|
||||
|
@ -75,6 +75,9 @@ const withTokenTracker = WrappedComponent => {
|
||||
}
|
||||
|
||||
updateBalance (tokens = []) {
|
||||
if (!this.tracker.running) {
|
||||
return
|
||||
}
|
||||
const [{ string, symbol }] = tokens
|
||||
this.setState({ string, symbol, error: null })
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user