useQuery staleTime doesn't work for local (fake) fetcher functions?
Hi people. I'm completely new to React Query, I wonder why adding
staleTime configuration (e.g., { staleTime: 20000 }) to this line doesn't work?
I expect the checked favorites to remain the same when I reload the page:
https://github.com/NarniaT/favorites-react/blob/c33178fca25f77ca65da619abfcb54f6dce397c2/src/hooks/useFavorites.ts#L12
getFavorites is a local (fake) fetcher, so React Query doesn't work in case of such local fetchers, or there's another issue I'm missing in my code?3 Replies
rare-sapphire•3y ago
The cache is in memory so everything is gone when you reload the page...
correct-apricotOP•3y ago
Oh! Haha, I was under the wrong impression. So I'll use a localstorage hook. Thanks for the info.
rare-sapphire•3y ago
You can use our persister plugin for that