You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 7, 2023. It is now read-only.
when we are doing http request and not yet completed the request, but we unmount the hooks or the component, then we will get error, because the http request still running and when completed then we do change state setResponse(json); or setError(error);.
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 the componentWillUnmount
method.
Solution
we should cancel the subscriptions of fetching, when the component will unmount.
when we are doing http request and not yet completed the request, but we unmount the hooks or the component, then we will get error, because the http request still running and when completed then we do change state
setResponse(json);
orsetError(error);
.Solution
we should cancel the subscriptions of fetching, when the component will unmount.
reference to fix:
https://stackoverflow.com/questions/31061838/how-do-i-cancel-an-http-fetch-request
https://stackoverflow.com/questions/53949393/cant-perform-a-react-state-update-on-an-unmounted-component
The text was updated successfully, but these errors were encountered: