-
-
Notifications
You must be signed in to change notification settings - Fork 521
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
Hydration mismatch error because initial CSR render differs from SSR render #1432
Comments
Here's a PR with my fix: #1436 |
Great job, so how do we add header authorization here. In particular, a cookie that is |
@productdevbook I'm confused, because these changes by definition only return what's already in the cache instead of triggering any requests or anything that would need headers or authentication cookies. |
Sooo, what is preventing this from getting merged? |
@Akryum thanks a lot for taking a stab at this so quickly! 🚀 |
Describe the bug
When using
useQuery
off@vue/apollo-composable
to load some data from an API in a SSR-supported app (e.g. Nuxt 3), Vue reports hydration mismatch errors during CSR even though SSR rendered the page correctly and after multiple passes CSR renders it correctly as well. The problem here is that this only happens after multiple render passes.It seems that SSR renders everything correctly, and CSR also does, but only on 2nd render pass. On initial render, even tho the Apollo cache is filled, it returns undefined at first, which causes Vue to report that there's a hydration mismatch.
(the error message seems off as well, its actually the inverse: SSR returns the full string, while CSR returns 'undefined' on first render pass)
To Reproduce
Repo: https://github.com/fabis94/nuxt3-apollo-hydration-error
See instructions in readme
Expected behavior
During CSR
useQuery
should return the already pre-cached data (from SSR) on first render, instead of returningundefined
at first and then only getting the data out from cache on 2nd render. This should make the Vue hydration errors disappear.Versions
vue: 3.2.45
@vue/apollo-composable: 4.0.0-beta.1
@vue/apollo-ssr: 4.0.0-alpha.18
@apollo/client: 3.7.0
Additional context
The text was updated successfully, but these errors were encountered: