Mar 14, 2021
If you suppress resolve and reject when promise is canceled, there is no need for this flag check. the article mentions it.
promise
.then((val) => (!isCanceled && resolve(val)))
.catch((error) => (!isCanceled && reject(error)));
Handling cancelable promises in a large app needs a more scalable solution such as the useAsync hook. https://codesandbox.io/s/one-hook-to-rule-them-all-zvt3u?file=/src/useAsync.ts