Skip to content
Advertisement

Cleaning up axios useEffect function

I keep getting this error for my useEffect.

JavaScript

How can I stop getting this warning for my function below?

JavaScript

I’m not sure what to add in the useEffect dependency array, I’ve tried using setAppState and the state itself but still getting this warning.

Advertisement

Answer

Check if the component is still mounted before calling setAppState:

JavaScript
Advertisement