I use Navigator component in my app, to render content of route i do http request with fetch to get data from server.
componentDidMount () {
fetch(url).then((res) => {
this.setState({data: res});
});
}
Problem I have is that sometimes fetch closure fires when component that called it is no longer mounted so I keep getting error that i'm trying to update unmounted component. This happens if you move quickly between routes. Is there a way to terminate closure execution if component is dismounted?