InvalidateQueries not refetching with dynamic key
I'm trying abstract away some boilerplate in our application. So, the queryKey is assigned by a prop in our case.
The list view works great, and the delete action also. But when I want to refresh the list (after deleting), nothing happens.
Query looks like:
-
queryClient.invalidateQueries([entityKey]); does nothing
- queryclient.invalidateQueries() also, does not refresh
According to the docs, just calling it with [entityKey] should expire all of the entity data, like list with pagination.
The delete API call is being executed directly (without mutation), is that necessary so that I can call invalidateQueries correctly?1 Reply
criminal-purpleOP•3y ago
OK, figured it out and hope if someone else does something similarly stupid - it will save them some time.
I was calling my "refresh" callback before actually mutating anything insert facepalm. So absolutely nothing wrong with React Query 👍