-
I'm using useInifiniteQuery fetching a long list of posts. I've set up a liked counter and button. I don't want to refetch the entire list of posts to revalidate the server's truth. I was wondering if there is a way to edit the cache data such that i can manipulate "number of likes". Much appriciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
be aware that infinite queries have a different structure (pages and pageParams) that you need to keep with your direct cache maniuplation. |
Beta Was this translation helpful? Give feedback.
queryClient.setQueryData
is for that use-case. You can just call it after the mutation to update the cache. It's described here: https://react-query.tanstack.com/guides/updates-from-mutation-responsesbe aware that infinite queries have a different structure (pages and pageParams) that you need to keep with your direct cache maniuplation.