#Can you invalidate / update a single item within userInfiniteQuery data?

2 messages · Page 1 of 1 (latest)

manic atlas
#

You can use setQueryData and update just that record, instead of invalidating.

https://tanstack.com/query/latest/docs/react/guides/updates-from-mutation-responses

When dealing with mutations that update objects on the server, it's common for the new object to be automatically returned in the response of the mutation. Instead of refetching any queries for that item and wasting a network call for data we already have, we can take advantage of the object returned by the mutation function and update the exis...

#

setQueryData gives you the oldData, so you return that, with the specific post updated.