Does the devtools appropriately indicate query state? #2484
Unanswered
ohansemmanuel
asked this question in
Ideas
Replies: 1 comment 1 reply
-
I agree that this is a general issue with the devtools - it seems that disabled queries are always displayed as stale. We have the following situation:
One question that has also come up very often is: Why am I seeing a cache entry for disabled queries at all? And the answer is pretty much the same: because it's a per-observer level, and the cache entry is technically there. One way to make this better would be to flag entries, or even hide them completely, if all observers are |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The What
Hey! I wasn't sure under what category to file this, but consider the following:
Please note the
staleTime
passed i.eInfinity
However, on inspecting the devtools, you get the following representation:
Technically speaking, I reckon
isStale
's value should follow the definition below:Essentially, the query with key
some-user-id
is NOT stale. Or is it? https://github.com/tannerlinsley/react-query/blob/master/src/devtools/utils.ts#L25If the query has the
enabled
option astrue
, you get the right representation i.e the query is considered as freshThe Discussion
In my opinion, I believe the mental model (or technical interpretation) for enabled and stale queries should perhaps not be mixed. I guess the bigger question is, "is a disabled query considered stale even on mount"?
It does appear that when a query is "disabled", the cache is invalidated and therefore considered stale. That makes sense.
However, if a query is mounted as "disabled" i.e., the enabled option as
false
, there's really nothing in the cache to be invalidated. The query should still be considered fresh and not stale. No? A fresh query that's inactive (or a disabled query) seems to fit the description than considering it stale.In terms of how this may be represented in the devtools, I reckon just dimming out a disabled query is enough to provide visual feedback. Similar to how the query "states" are represented https://github.com/tannerlinsley/react-query/blob/master/src/devtools/devtools.tsx#L511
Conclusion
That turned out longer than I had planned for! Let me know your thoughts and if I've managed to ramble on for too long.
Beta Was this translation helpful? Give feedback.
All reactions