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

suspense mode fetches twice when no prefetching #51

Closed
tibotiber opened this issue Nov 25, 2019 · 9 comments
Closed

suspense mode fetches twice when no prefetching #51

tibotiber opened this issue Nov 25, 2019 · 9 comments

Comments

@tibotiber
Copy link
Contributor

tibotiber commented Nov 25, 2019

Hello,

I've been fighting a double fetch issue which I thought came from my custom hook that wraps useQuery. Turns out it seems to come from useQuery itself.

When using the suspense mode, the fetch function is called twice, once on initial render, and once when the data comes in. This only happens if the query was not prefetched. I've forked your codesandbox and disabled prefetching of projects when you click "Show projects", I've also added a log at the start of the fetch function so it's easy to debug in the console.

Have a look here: https://codesandbox.io/s/react-query-double-fetch-q5zgl

Let me know if there is additional details I can provide.

Thanks!

EDIT: note that I've noted tried the non-suspense mode. I'm assuming this is a suspense only issue.

@tannerlinsley
Copy link
Collaborator

tannerlinsley commented Nov 25, 2019 via email

@tannerlinsley
Copy link
Collaborator

Fixed in 0.3.17

1 similar comment
@tannerlinsley
Copy link
Collaborator

Fixed in 0.3.17

@tibotiber
Copy link
Contributor Author

Yep, tested and we're all good. Thanks for the quick release :).

@tannerlinsley
Copy link
Collaborator

tannerlinsley commented Nov 26, 2019 via email

@amanolar94
Copy link

amanolar94 commented Feb 17, 2020

Hello @tannerlinsley!
First of all amazing work on the whole project.
I still stumble upon the same issue with suspense enabled on the latest version.
Is there maybe a hint on why this is happening?

Thank you!

EDIT: I downgraded my react-query version to 0.3.17 just to make sure that I'm not missing something and it does not fetch twice indeed

@simoncarpinter
Copy link
Contributor

Raised #342 with a test for this behaviour :)

@tibotiber
Copy link
Contributor Author

tibotiber commented Apr 7, 2020

@simoncarpinter meant #324? Nice work with the test, a good start :)

@simoncarpinter
Copy link
Contributor

I did, yes, doh!

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

4 participants