Infinite request fetches when staleTime is 0 #4068
-
When I'm not sure if this is the intended behaviour and there is some gap in my understanding of how react-query works. Would be glad to get some pointers. Codesandbox to replicate this: https://codesandbox.io/s/nice-davinci-kl0bz8?file=/src/App.tsx Tested on react-query v3 and v4. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This behaviour is pretty easy to explain: It's because you listen to
rinse and repeat ad nauseam. My guess is that you actually want to check for |
Beta Was this translation helpful? Give feedback.
This behaviour is pretty easy to explain: It's because you listen to
isFetching
, which unmountsChild1
.isFetching
is also true for background refetches (basically, every time when a request is in-flight). So what happens is:isFetching:true
, which makes the parent unmount Childrinse and repeat ad nauseam.
My guess is that you actually want to check for
isLoading
, notisFetching
? Working reproduction here: https://codesandbox.io/s/magical-mclean-o339fe?file=/src/App.tsx