-
Hi all, I'm new to react-query, doing research on whether I should use it. My biggest problem in my app is I have fetched a huge list of items with one query, on-load. Then I allow user a button on each entry, clicking it mutates the entry. After mutation, I don't want to invalidate the cache and refetch the huge list. The mutation returns the updated entity. Is it possible to make the mutation update the cache rather then invalidate and refetch? The getting started docs show this example below. We see after "adding the todo" item it is refetcthing the entire list. Can we make it not refetch from server? And just add the response of the mutation into the list?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Yes, you can write to the cache directly in onSuccess. Have a look here: https://react-query.tanstack.com/guides/updates-from-mutation-responses |
Beta Was this translation helpful? Give feedback.
Yes, you can write to the cache directly in onSuccess. Have a look here: https://react-query.tanstack.com/guides/updates-from-mutation-responses