T
TanStack2w ago
harsh-harlequin

Setting state cache on success

In my app, there is a location selector. Each location has an id and a name. I store the id and name of the selected location in local storage so that I can show the app chrome immediately. The name falls back to the name fetched from the server once a useQuery completes. However, if the name has changed or the location has been deleted, I want to update the local cache. Is the correct way to do this in the queryFn? This thread recommends a pure queryFn but then doesn't after the callbacks are removed. Curious if anyone has insights or recommendations!
GitHub
Side effects in useQuery function or outside of useQuery in a useEf...
Describe the bug Do the author or the contributors of this library have any opinions on the presence of side effects in the useQuery function, or should side effects be outside of useQuery in a use...
1 Reply
fair-rose
fair-rose2w ago
It's fine from inside the queryFn imo. Or use the global cache callbacks

Did you find this page helpful?