DEV Community

Discussion on: Avoiding race conditions and memory leaks in React useEffect

Collapse
 
saranshk profile image
saransh kataria • Edited

I would rather use a polyfill than use axios, but that is again a personal preference. If there are other features that axios provides (specific to the use case), I might go for it. You could just use the first approach of a boolean flag as well.

But if it is just cancellation support for IE, you could take a look at the example repo

Install:

  • promise-polyfill
  • unfetch
  • abortcontroller-polyfill

Add the following:

import 'promise-polyfill/src/polyfill';
import 'unfetch/polyfill';
import 'abortcontroller-polyfill';
Enter fullscreen mode Exit fullscreen mode
Collapse
 
devhammed profile image
Hammed Oyedele

There are other features like request and response interceptors that axios provides by the way.

Thread Thread
 
saranshk profile image
saransh kataria

As I mentioned, if there are other features that you are using, go for it. But most people are not using those features, thus the recommendation.