-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useQuery pollInterval props still triggered even after unmount #6391
Comments
I got the same issue Version: |
Let us know if this is still a concern with |
@hwillson Thanks for checking in. I still see this same behavior when using To see the bug, you'll have to:
If you toggle more times, you'll see it keeps adding yet more polling instances on top of the original (so it'll be polling more often than every second). This issue should be re-opened. I tried myself to investigate how to fix in the Apollo code a few months ago but had a bit of trouble wrapping my head around a lot of the Apollo client internals. Would greatly appreciate a fix 🙏 (This has outright prevented my team from using |
(There's this other issue from October that may also be related #7221) |
I'm also experiencing this. Seems like there's some movement on it, but this has already been a long-term bug. Will there be a fix soon? |
This comment (on a related polling issue) #7221 (comment) seems to be relevant here as well. Adding apollo-client/src/react/hooks/__tests__/useQuery.test.tsx Lines 588 to 592 in 67fe4e8
should stop polling when the component is unmounted test.
Similarly, removing Presumably this is due to React double-invoking lifecycle methods to help detect unwanted side-effects (https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects). So this particular bug will seemingly occur in development only right now, though is potentially indicative of some other issues with the hook. IMO definitely still worth solving (esp since folks are very unlikely to have confidence in this working properly if development has bugs). |
Seems there's another StrictMode-related issue that has gotten a fair amount of attention/upvotes but no traction toward a solution: #6037 |
Intended outcome:
after component is unmounted useQuery pollInteval shouldn't be triggered again.
Actual outcome:
useQuery still refetch data even after unmount
How to reproduce the issue:
https://codesandbox.io/s/apollo-client-pollinterval-bug-1d0ns?file=/src/App.js
Versions
this issue still exist on 3.0.0-rc1
The text was updated successfully, but these errors were encountered: