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
Not sure if this is either a bug or just missing documentation, but essentially if you call removeQueries, and another component has useQuery mounted with the same key, it will no longer re-render when new data is set to that key.
The only way to "re-attach" that useQuery instance to the queryKey is to get the component to re-render
Setup parent component with a listener on useQuery({queryKey: ['my-key']})
Add action action to child component that updates the value for my-key and refetches
Add action button to child component that calls removeQueries({queryKey: ['my-key']})
Click the actions to see the behavior.
Expected behavior
I would expect a refetch to update caches across all components. If that's not the expected behavior for removeQueries, may want to update the docs to reflect that
How often does this bug happen?
Every time
Screenshots or Videos
Screen.Recording.2025-01-28.at.11.22.11.AM.mov
Platform
OS: macOS 15.2
Browser: Chrome 132.0.6834.111
Tanstack Query adapter
react-query
TanStack Query version
4.3
TypeScript version
5.4
Additional context
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
Not sure if this is either a bug or just missing documentation, but essentially if you call
removeQueries
, and another component hasuseQuery
mounted with the same key, it will no longer re-render when new data is set to that key.The only way to "re-attach" that
useQuery
instance to the queryKey is to get the component to re-renderYour minimal, reproducible example
https://stackblitz.com/edit/removequeries-detachment-query-6y1qnf2s?file=src%2Findex.tsx
Steps to reproduce
useQuery({queryKey: ['my-key']})
my-key
and refetchesremoveQueries({queryKey: ['my-key']})
Expected behavior
I would expect a
refetch
to update caches across all components. If that's not the expected behavior forremoveQueries
, may want to update the docs to reflect thatHow often does this bug happen?
Every time
Screenshots or Videos
Screen.Recording.2025-01-28.at.11.22.11.AM.mov
Platform
Tanstack Query adapter
react-query
TanStack Query version
4.3
TypeScript version
5.4
Additional context
No response
The text was updated successfully, but these errors were encountered: