queryClient.invalidateQueries works... but only for a while
Hi,
I have the following. I want to refetch the list of favourites from my API every time a user favourites or unfavourites an item. This code works as expected, the app will send a POST or DELETE request, invalidate the queries, and make a GET request to refresh the favourites. But after a short amount of time, say ten minutes or so, it stops working. It will send the POST or DELETE, but the queries do not get invalidated to the favourites are never refreshed
5 Replies
ambitious-aquaOP•3y ago
Also worth noting my API logs show the POST/DELETE requests were successful, so onSuccess should run, and the queries should be invalidated
And I've just determined onSuccess is called, so the issue is the QueryClient not invalidating the queries
fascinating-indigo•3y ago
Seems like the query is not actively used and thus garbage collected. The devtools would show them as inactive in that case.
ambitious-aquaOP•3y ago
Thanks, I'll keep an eye out in Flipper although it hasn't happened again since posting this
If that's the case is there a way I can prevent it?
fascinating-indigo•3y ago
a query is used when a component is mounted and that component has a useQuery call
ambitious-aquaOP•3y ago
So it's started happening again and all the queries are showing as active in flipper