Is there a way to manually set the entire cache to a new value?
I need to update a value that appears in many places so I wanted to avoid passing a
queryKey to setQueryData(). I've written a recursive function that gets the entire cache and updates every occurance of the value and returns a new array. How can I set the cache to this new array?
(If there is a better way of doing what I'm doing I'm open to suggestions)
Thanks3 Replies
ambitious-aqua•2y ago
QueryClient | TanStack Query Docs
QueryClient
The QueryClient can be used to interact with a cache:
ambitious-aqua•2y ago
What about this?
Apply your function as the updater of setQueriesData 🙂
stormy-goldOP•2y ago
Great suggestion I didn't notice that function in the docs. Works a treat thank you