Can anyone explain why this query hit multiple times (and even infinite loop) instead of only once? #4802
-
So I've created this sandbox to get the exact situation I'm running into (using dummy scenario). Basically I have 1 reusable useQuery named
The result was:
Would be appreciated if anyone can explain what is going on here, why point 2 & 3 didn't hit 1x too? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Did you ever get any answer on this? I keep having infinite rendering issues with the exact same condition. |
Beta Was this translation helpful? Give feedback.
-
There have been other discussions about this, the reason is always the same thing:
you probably don't want to unmount Child whenever the query |
Beta Was this translation helpful? Give feedback.
There have been other discussions about this, the reason is always the same thing:
refetchOnMount
defaults totrue
andstaleTime
defaults to zero.isFetching: true
, which will trigger a re-render of the parent and unmountChild
(in case of!isFetching && <Child />
)Child
again, putting you right back at 2) and you'll go infinite.you probably don't want to unmount Child whenever the query
isFetching
- maybe you meant to check forisLoading
instead?Also, you might want to se…