T
TanStack2y ago
conscious-sapphire

Does getQueryData function return a reference to the cached data?

Suppose I have a cached product. I have the following: const product = queryClient(["Product","some_id"]); //Knowing that, the product price is 20 at the beginning. // Some code here product.price = 14; This will change product price into cache directly. So, is getQueryData a reference to the cached product?
1 Reply
rival-black
rival-black2y ago
Updates from Mutation Responses | TanStack Query Docs
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...

Did you find this page helpful?