3 ms·
For example, you can wrap a promise such that when it finally resolves, it checks an isCancelled flag and rejects instead so that your .then callbacks aren't ru
by always_good 9y ago
For example, you can wrap a promise such that when it finally resolves, it checks an isCancelled flag and rejects instead so that your .then callbacks aren't run.
It's not about cancelling any potential inflight action within the promise itself.
In this case, you don't want the callback to run after the react component unmounts, nor do you want to hold a reference to the component:
promise
.then(value => this.setState({ value }))