Cancel Request.
apenab opened this issue · 3 comments
apenab commented
Hi, good work guys.
I think about the implementation of canceling the request when the component is unmounted, cancel the previous request and add a type of debounce.
What do you think about this?
jannotti commented
If this is to avoid calling setState on unmounted component, this might be simpler.
React.useEffect(() => {
let didCancel = false;
// ...
// you can check didCancel
// before running any setState
// ...
return () => {
didCancel = true;
};
});
Was recommended in discussion here: facebook/react#14369
int64ago commented
Via 1.1.1