From 727e80985704c0c97a5c8390a555d3876c2644a7 Mon Sep 17 00:00:00 2001 From: meriadec Date: Wed, 13 Jun 2018 09:02:36 +0200 Subject: [PATCH] Prevent WithFeesAPI settings its state after unmount --- src/components/WithFeesAPI.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/WithFeesAPI.js b/src/components/WithFeesAPI.js index a3b3b6ba..5a56a347 100644 --- a/src/components/WithFeesAPI.js +++ b/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() {