isLoading
vs isFetching
: How to avoid hard refresh without constant spinner display?
#5593
Unanswered
aguirrealvaro
asked this question in
General
Replies: 1 comment 6 replies
-
It would be easier to see an example, but I think you're talking about a changing queryKey? In this case, you'd want |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If the data is stale and stored in the cache (defaults), React Query retrieves the data from the cache and performs a background fetch.
Using
isLoading
, I will only see the spinner the first time, as subsequent requests will retrieve the data from the cache.If I use
isFetching
, I will see the spinner with each background fetch.Suppose that during a background fetch, React Query detects a change in the response. In this case, using
isLoading
, a hard refresh occurs (the value updates without showing a spinner)To avoid this hard refresh, I can use
isFetching
, but then I'll face the issue of always seeing the spinner, even when obtaining the data from the cache. However, the purpose of React Query is to solve this problem of having multiple spinners for data fetching.Am I missing something or is there something I'm not understanding correctly? How can i solve this?
Beta Was this translation helpful? Give feedback.
All reactions