Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch loop on repeated mounting and un-mounting #8

Closed
john-pc opened this issue Oct 9, 2019 · 3 comments
Closed

Fetch loop on repeated mounting and un-mounting #8

john-pc opened this issue Oct 9, 2019 · 3 comments

Comments

@john-pc
Copy link

john-pc commented Oct 9, 2019

I've noticed a strange behaviour on repeated mounting and un-mounting.
What happens is that i have tabs component that mounts a specific components on every tab change,
so every time i switch between tabs, the current tab component is mounted again.
I'm using useQuery on each components to fetch the relevant information for the current tab.
When i'm doing the following actions the useQuery getting into fetch loop that never ends.

  1. mount the current tab component
  2. useQuery fetches the data
  3. move to other tab ( the previous component now unmounted and a new component tab mounted)
  4. get back to the first tab component ( now after the cacheTimeout has been expired )
  5. useQuery now getting into fetching loop with infinite fetch requests.

See the video below:
https://streamable.com/a90vs

Hope i'm clear enough, let me know if you need more information in order to reproduce it.

Thank you so much!

@tannerlinsley
Copy link
Collaborator

tannerlinsley commented Oct 9, 2019

Interesting indeed. I wonder if we could get this to happen in a simple codesandbox that I can debug?

@john-pc
Copy link
Author

john-pc commented Oct 9, 2019

Great idea - i will prepare one

@john-pc john-pc closed this as completed Oct 9, 2019
@john-pc john-pc reopened this Oct 9, 2019
@john-pc
Copy link
Author

john-pc commented Oct 10, 2019

@tannerlinsley after many failed attempts to try and reproduce it in codesandbox , i've updated react and react-query package and the problem was gone..
it will remain a mystery ...

@john-pc john-pc closed this as completed Oct 10, 2019
TkDodo added a commit to TkDodo/react-query that referenced this issue Jun 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants