T
TanStack•2y ago
correct-apricot

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) Thanks
3 Replies
xenial-black
xenial-black•2y ago
xenial-black
xenial-black•2y ago
What about this? Apply your function as the updater of setQueriesData 🙂
correct-apricot
correct-apricotOP•2y ago
Great suggestion I didn't notice that function in the docs. Works a treat thank you

Did you find this page helpful?