isFetching for one section of a page #6541
Unanswered
jamesarosen
asked this question in
Q&A
Replies: 1 comment
-
yeah, you've analyzed the trade-off pretty well. You can't have your cake and eat it, too. Choose your poison: separate caches or specifying keys :) |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
I'm trying to add an "is fetching" indicator to each of three separate sections of a page. The idea is that if any query within that section has
isFetching: true
, the indicator next to that section shows up.Reading #3339, I know one option would be to add a
predicate
toisUseFetching
:The downside to this is that I need to know that
foo
andbar
are the keys used in Section One, whilebar
andbaz
are used in Section Two. It's not automatic, so it will get out of sync as the sections change.My second idea was to use separate query-providers for each section:
With this, I don't need to maintain the
predicate
for each section. The downside is that I've disconnected my caches. Section One and Section Two now fetch the same data independently.I can give them the same cache object (or use nested QueryProviders), but since QueryClient implements isFetching in terms of queryCache, I'd end up with the original problem: if any query were fetching, all sections would light up.
Has anyone done something like this?
Beta Was this translation helpful? Give feedback.
All reactions