TanStack-query v5: best way to filter by using cached data
There is fetched data from server. I want to reuse the data without fetching again. Note that in the useMovieByCategory(), I call useMovies() to “reuse” the cached data. I wonder if it’s a right approach and efficient way. using select inside of useQuery will make fetch again. So this is not a desired since I […]
Why data doesn’t re-fetch when staleTime set to Infinity and cacheTime set to zero in React Query
I am starting to learn ReactQuery. I’ve gone through multiple articles which mentioned that data won’t re-fetch when staleTime: Infinity and cacheTime: 0. I would like to understand how this works.
From my understanding, cacheTime is the time till which the data stays in the cache before it is garbage collected/deleted. In this case as the cacheTime is set to zero, when there is component unmount, the cached data is garbage collected immediately.
Now if there is window refocus (or any trigger point), as there is no data to be fetched from cache so how is it possible to not make a re-fetch and still have the data?