Browse Source

Prevent WithFeesAPI settings its state after unmount

master
meriadec 7 years ago
parent
commit
727e809857
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 8
      src/components/WithFeesAPI.js

8
src/components/WithFeesAPI.js

@ -21,13 +21,17 @@ export default class WithFeesAPI extends Component<
componentDidMount() {
this.load()
}
componentWillUnmount() {
this._unmounted = true
}
_unmounted = false
async load() {
const { currency } = this.props
try {
const fees = await getEstimatedFees(currency)
this.setState({ error: null, fees })
if (!this._unmounted) this.setState({ error: null, fees })
} catch (error) {
this.setState({ error, fees: null })
if (!this._unmounted) this.setState({ error, fees: null })
}
}
render() {

Loading…
Cancel
Save