Skip to content
Discussion options

You must be logged in to vote

This behaviour is pretty easy to explain: It's because you listen to isFetching, which unmounts Child1. isFetching is also true for background refetches (basically, every time when a request is in-flight). So what happens is:

  • App fetches data, data is there, Child is rendered
  • Because of staleTime:0, the mounting of Child triggers a background refetch.
  • This sets isFetching:true, which makes the parent unmount Child
  • fetch completes, Child mounts and fetches again

rinse and repeat ad nauseam.


My guess is that you actually want to check for isLoading, not isFetching ? Working reproduction here: https://codesandbox.io/s/magical-mclean-o339fe?file=/src/App.tsx

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@blenderskool
Comment options

Answer selected by blenderskool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants