T
TanStack4y ago
yelping-magenta

arguments for queryClient.removeQueries

If I have the following request and I want to stop a refetch could I write the ,following command to remove the query? ["streets",{"streetid":15},"waypoints","power",{"rain":1,"steepfactor":2}] queryClient.removeQueries("streets", streetid, "waypoints", "power"); can I pass more than two arguments to removeQueries? or is it just possible to pass a wildcard and power to remove old power ones?
4 Replies
yelping-magenta
yelping-magentaOP4y ago
some waypoints will change and trigger an refetch but if that is trigged all power ones should not be refetched. can I check with if - if there is already a query like that to remove it?
fascinating-indigo
fascinating-indigo4y ago
removeQueries doesn't stop refetches so I don't understand what you're trying to do
yelping-magenta
yelping-magentaOP4y ago
If the component is open and rendered and then a change of the waypoint happens it would trigger a refetch or? I would like to stop that refetch. queryClient.removeQueries with the queryKey, it will remove the query from the cache and not re-render the components, so the query will stay rendered on the screen if its rendered. Or? Easy: I want that query to not refetch if sometimes changes. Only if the component gets closed / openend again Thank you very much for your help!
fascinating-indigo
fascinating-indigo4y ago
If parts of the key change and there is no data for that key it must be fetched. Otherwise it will be taken from the cache. To avoid refetches, set staleTime

Did you find this page helpful?