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

@apollo/[email protected]: SSR: useQuery returns loading and data, then runs a second time #5947

Closed
bwhitty opened this issue Feb 14, 2020 · 2 comments

Comments

@bwhitty
Copy link
Contributor

bwhitty commented Feb 14, 2020

Intended outcome:
Upon initial reactDOM.hydrate() of SSR'd components, I do not expect useQuery() to run twice.

Currently it runs once returning

{ loading: true, data: { some: 'data' } }

and then a second time returning

{ loading: false, data: { some 'data' } }

I would expect an Apollo Client cache which has data via cache.restore() already to only run once during SSR hydration, returning

{ loading: false, data: { some 'data' } }

Actual outcome:
During initial "React hydration" of SSR'd components, I am seeing both loading: true and data present from useQuery(), and then the query is immediately re-ran again, and loading: false and data is the next state:
Screen Shot 2020-02-14 at 12 51 50 PM

How to reproduce the issue:

  1. Load https://codesandbox.io/s/apollo-client-3-ssr-hydration-mismatch-x51p3
  2. Look at the console
  3. (if you don't see any logs in the console, hard-refresh the codesandbox)

Also posted on Spectrum chat https://spectrum.chat/apollo/apollo-client/loading-true-and-data-during-initial-ssr-re-hydration-3-0-beta~0fca008b-1954-4003-9132-66a0e84ac3f3

Versions

@bwhitty bwhitty changed the title @apollo/[email protected]: useQuery returns loading and data, then runs a second time @apollo/[email protected]: SSR: useQuery returns loading and data, then runs a second time Feb 14, 2020
@vishwam
Copy link
Contributor

vishwam commented Feb 15, 2020

This is the same issue as #5869

@hwillson
Copy link
Member

hwillson commented Aug 3, 2020

I've verified this is no longer an issue with @apollo/[email protected]. Thanks!

@hwillson hwillson closed this as completed Aug 3, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants