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 to 3.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 use React.StrictMode and set the fetchPolicy for watchQuery to cache-and-network. Duplicate queries do not occur if I remove React.StrictMode or use the default fetchPolicy for watchQuery.
How to reproduce the issue:
You can see the issue with a very basic Create React App + Apollo here
- refresh the inner browser and see the page reload twice
- inspect the network tab to see graphql request issued twice
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 between 3.0.0 and 3.1.0.
Versions
3.0.0 - works
3.1.0 - regression with double queries
Thanks for any insights!
Intended outcome:
See a component mounted once and queries / network requests issued once in the browser while using
React.StrictModeActual outcome:
We recently upgraded from
@apollo/client:3.0.2to3.1.2and 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.StrictModeand set thefetchPolicyforwatchQuerytocache-and-network. Duplicate queries do not occur if I removeReact.StrictModeor use the defaultfetchPolicyforwatchQuery.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.0here with otherwise identical code and the issue is gone and client runs as expected, so it seems to be a regression between3.0.0and3.1.0.Versions
3.0.0- works3.1.0- regression with double queriesThanks for any insights!