alan2207 / react-query-auth

⚛️ Authenticate your react applications easily with react-query.
MIT License
366 stars 43 forks source link

cleanup function #5

Closed musicformellons closed 3 years ago

musicformellons commented 3 years ago

I am using code very similar to this codepen, but when I login using an axios call I get this warning:

index.js:1 Warning: 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. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.
    at Login (http://localhost:3000/static/js/main.chunk.js:2036:67)
    at Route (http://localhost:3000/static/js/vendors~main.chunk.js:55437:29)

Probably I should cleanup my axios call somehow, but I do not really have clue how to do that?! Tried, but no success so far. I think the useEffect must be in the library as it is not in my code?!

musicformellons commented 3 years ago

Indeed needed to take care of cancellation of Axios in the loginFn, then warning was gone.