by jbaudanza · 9y ago · 0 comments
Facebook discusses this on its blog: https://reactjs.org/blog/2015/12/16/ismounted-antipattern.ht...
I've been using Observables which, in my experience, bind a little cleaner than Promises to React components.
I've thought it's just technically impossible (no API to do so) to cancel a `fetch` request in progress.
But I would never do something like that in, say, the constructor of a WPF/UWP windows app as those have "Loaded" or "Loading" events of some kind (which is parallel to componentDidMount).
The React lifecycle has `componentDidMount` for doing stuff (at most once) after rendering.
Once the component mounts, then it can be unmounted. The upstream comment is talking about when you have a promise that is still running after unmount.
this.cancelOnUnmoun(new Promise(...)).then(...)