A use case for isFetching and isLoading flags #2924
Unanswered
ZaeemKhaliq
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The
isLoading
flag only works when a fetch query triggers for the first time. However, I want this flag to also work whenever thearg
to the query changes.For example, I have a
Card
component, where I show an individual product's details with apollingInterval
of 10 seconds. When the query is triggered for the first time, I show some loaders based onisLoading
flag which only works initially, to show initial loading of data in UI. After that, after every 10 seconds a re-fetch occurs but it doesn't show loaders (which is what I want, we just show user initial loading of data and afterwards we don't show loaders on every update after 10 seconds) becauseisLoading
flag doesn't change.However, what I want is that if a different product is selected (
arg
are changed), theisLoading
flag should work for changed arguments initially (since arguments are changed, this is the first time we are fetching data for changed arguments and so I have to show loaders), but it only changesisFetching
flag sinceisLoading
works only for the very first fetch.Is there any way to handle this?? TIA for any help.
Beta Was this translation helpful? Give feedback.
All reactions