I have the code below
const [status, statusSetter] = useState({ isAuthenticated: false });
useEffect(() => {
let didCancel = false;
async function fetchMyAPI() {
if (!didCancel) {
let response = (await axios.get('api/auth/getuserstatus')).data;
statusSetter(response);
}
}
fetchMyAPI();
return () => {
didCancel = true;
}
}, []);
I have tried implementing the didcancel
as a form of clean up for userEffects but it doesnt work. I get the following error:
"Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. "
what am i supposed to put in my clean up?