T
TanStack2y ago
deep-jade

Track data changes

Hi All, What is the bast way to subscribe to updates of my cache in such a way that I only get notified if the data has changed? Doing this from a different place in my app than where I use the useQuery hook. Also, how can I validate structuralSharing is working properly? Is there any quick debug I can use to check this?
4 Replies
genetic-orange
genetic-orange2y ago
Structural sharing: refetch and see if it triggers a rerender if data stays the same Just use the useQuery hook in your different place again?
deep-jade
deep-jadeOP2y ago
Is there a way to do it without using the useQuery hook?
genetic-orange
genetic-orange2y ago
Why would you want that??
deep-jade
deep-jadeOP17mo ago
I want to keep track of data changes without defining the queryFn or any other options. I am now using a wrapper hook that just defines the queryFn and options for me and I can use that to subscribe to updates of data. However I am using experimental_createPersister and at the start of the app data is "updated" but was not changed. I dont want to run my code in this case.

Did you find this page helpful?