What is an "inactive" query? #1913
-
From the documentation below, it's not clear to me what an "active instances of useQuery, ..." means.
is there an explanation (hopefully with some example) that explains this further? This is important for me to understand to decide what flags to pass below
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I think this is a good definition by example: https://react-query.tanstack.com/guides/caching Basically, every time you call |
Beta Was this translation helpful? Give feedback.
I think this is a good definition by example: https://react-query.tanstack.com/guides/caching
Basically, every time you call
useQuery
, you create anobserver
. As long as your component that callsuseQuery
is mounted, the query is consideredactive
(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 ascacheTime
. This is nice because when you come back to your page, making your query active again, you can again lever…