-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Network requests get run twice with React.StrictMode and watchQuery.fetchPolicy: 'cache-and-network' #6832
Comments
Yeah this just bit me in the behind. For the Apollo team: I'd reckon if people are logging issues related to query fetching that you can't replicate, one of the first questions should be "Are you using strict mode?". Perhaps a note in the docs to not use strict mode (until this is fixed) would save a lot of people a lot of time. |
Get similar issue with |
encountering this issue on |
Still got this in With StrictMode, we began to see an infinite request loop. Disabling strictmode solved the issue. |
@bstro Can you try the 3.5 beta? We did a bunch of refactoring which might help with StrictMode bugs. |
This is still an issue for us as of |
Intended outcome:
See a component mounted once and queries / network requests issued once in the browser while using
React.StrictMode
Actual outcome:
We recently upgraded from
@apollo/client:3.0.2
to3.1.2
and are noticing components re-rendering and queries / network requests getting issued twice with the same data while dependencies remain the same. This issue only occurs in development, where we useReact.StrictMode
and set thefetchPolicy
forwatchQuery
tocache-and-network
. Duplicate queries do not occur if I removeReact.StrictMode
or use the defaultfetchPolicy
forwatchQuery
.How to reproduce the issue:
You can see the issue with a very basic Create React App + Apollo here
I was able to revert to
@apollo/client:3.0.0
here with otherwise identical code and the issue is gone and client runs as expected, so it seems to be a regression between3.0.0
and3.1.0
.Versions
3.0.0
- works3.1.0
- regression with double queriesThanks for any insights!
The text was updated successfully, but these errors were encountered: