Skip to content
Discussion options

You must be logged in to vote

I think this is a good definition by example: https://react-query.tanstack.com/guides/caching

Basically, every time you call useQuery, you create an observer. As long as your component that calls useQuery is mounted, the query is considered active (can be stale or fresh or fetching, but it's active).
When you unmount all observers (because of conditional rendering, or you navigate to a different page via client-side routing), you don't really need the data anymore - your query is now inactive. The data will still stay in the cache for 5 more minutes - or whatever you set as cacheTime. This is nice because when you come back to your page, making your query active again, you can again lever…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@vineetdigit
Comment options

@shivammalhotra859
Comment options

Answer selected by vineetdigit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants