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
Describe the bug
When we fetch data with a request using useQuery from"@apollo/react-hooks"and update a React component state according to the request, we sometimes update a component state (due to async nature of requests) after the component unmounts. This results in a warning like this:
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.
After that i tried to reproduce the warning (since we use useQuery everywhere), i managed to get the same warning in a different page as well (reports/Form.js):
To Reproduce
Steps to reproduce the behavior (this was by luck, maybe there is a more consistent way to reproduce like slowing network request etc):
Go to a page with data request
Very quickly click on some link which can unmount the component (which has logic to set some state after request)
If you clicked before request finished, look at the console for warning
Expected behavior
No warnings in the console.
Screenshots
Environment (please complete the following information):
Browser [Chrome v85]
Additional context
The text was updated successfully, but these errors were encountered:
Another one at reports/Show.js (Clicked a read report with LikertScale component + immediately navigating away from that page ).
EDIT: this was cause by react-use-dimensions not useQuery, react-use-dimensions call requestAnimationFrame ( which does the same kind of async state stating)
These warnings are mainly coming from the libraries and not really critical from users' perspective. I will close this as the only thing we can do about it is to change the libraries which is a major work for such a minuscule problem.
Describe the bug
When we fetch data with a request using
useQuery
from"@apollo/react-hooks"
and update a React component state according to the request, we sometimes update a component state (due to async nature of requests) after the component unmounts. This results in a warning like this: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.
This is an open issue waiting to be resolved from apollo-client: apollographql/apollo-client#4955 which we encountered here:
#3017 (review)
After that i tried to reproduce the warning (since we use useQuery everywhere), i managed to get the same warning in a different page as well (reports/Form.js):
To Reproduce
Steps to reproduce the behavior (this was by luck, maybe there is a more consistent way to reproduce like slowing network request etc):
Expected behavior
No warnings in the console.
Screenshots
Environment (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: