Browse Source
Prevent WithFeesAPI settings its state after unmount
master
meriadec
7 years ago
No known key found for this signature in database
GPG Key ID: 1D2FC2305E2CB399
1 changed files with
6 additions and
2 deletions
-
src/components/WithFeesAPI.js
|
@ -21,13 +21,17 @@ export default class WithFeesAPI extends Component< |
|
|
componentDidMount() { |
|
|
componentDidMount() { |
|
|
this.load() |
|
|
this.load() |
|
|
} |
|
|
} |
|
|
|
|
|
componentWillUnmount() { |
|
|
|
|
|
this._unmounted = true |
|
|
|
|
|
} |
|
|
|
|
|
_unmounted = false |
|
|
async load() { |
|
|
async load() { |
|
|
const { currency } = this.props |
|
|
const { currency } = this.props |
|
|
try { |
|
|
try { |
|
|
const fees = await getEstimatedFees(currency) |
|
|
const fees = await getEstimatedFees(currency) |
|
|
this.setState({ error: null, fees }) |
|
|
if (!this._unmounted) this.setState({ error: null, fees }) |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
this.setState({ error, fees: null }) |
|
|
if (!this._unmounted) this.setState({ error, fees: null }) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
render() { |
|
|
render() { |
|
|