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 = []) {
|
TokenBalance.prototype.updateBalance = function (tokens = []) {
|
||||||
|
if (!this.tracker.running) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const [{ string, symbol }] = tokens
|
const [{ string, symbol }] = tokens
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -110,5 +114,7 @@ TokenBalance.prototype.updateBalance = function (tokens = []) {
|
||||||
TokenBalance.prototype.componentWillUnmount = function () {
|
TokenBalance.prototype.componentWillUnmount = function () {
|
||||||
if (!this.tracker) return
|
if (!this.tracker) return
|
||||||
this.tracker.stop()
|
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) {
|
TokenList.prototype.updateBalances = function (tokens) {
|
||||||
|
if (!this.tracker.running) {
|
||||||
|
return
|
||||||
|
}
|
||||||
this.setState({ tokens, isLoading: false })
|
this.setState({ tokens, isLoading: false })
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenList.prototype.componentWillUnmount = function () {
|
TokenList.prototype.componentWillUnmount = function () {
|
||||||
if (!this.tracker) return
|
if (!this.tracker) return
|
||||||
this.tracker.stop()
|
this.tracker.stop()
|
||||||
|
this.tracker.removeListener('update', this.balanceUpdater)
|
||||||
|
this.tracker.removeListener('error', this.showError)
|
||||||
}
|
}
|
||||||
|
|
||||||
// function uniqueMergeTokens (tokensA, tokensB = []) {
|
// function uniqueMergeTokens (tokensA, tokensB = []) {
|
||||||
|
|
|
@ -75,6 +75,9 @@ const withTokenTracker = WrappedComponent => {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateBalance (tokens = []) {
|
updateBalance (tokens = []) {
|
||||||
|
if (!this.tracker.running) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const [{ string, symbol }] = tokens
|
const [{ string, symbol }] = tokens
|
||||||
this.setState({ string, symbol, error: null })
|
this.setState({ string, symbol, error: null })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue