Hydratation bug with first render
See original GitHub issueHello,
I have followed the instructions in the readme but my page when it loads does the same query as the ssr page. However there is the NEXT_DATA with the right data. My cache is not hydrated, is it possible to have the source code of the demo so that I understand what I did wrong?
also:
In a page contained by WithApollo
export default WithApollo( { ssr : true } )( Home );
I have as props:
(2) [{…}, {…}]
0: {apolloState: {…}, apolloClient: null}
1: {}
The apolloState has the right data, how can I pass them to Apollo client ?
Thanks! 😃.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Debugging and fixing hydration issues - somewhat abstract
As you may recall, for hydration to work properly, the initial render cycle of our React app on both the server and client...
Read more >Avoiding hydration mismatch when using React hooks
A React hook or component MUST NOT return or render different values on the server and during the first render pass in the...
Read more >Bug: Incorrect Hydration Mismatch Detection during Suspense ...
Bug : Incorrect Hydration Mismatch Detection during Suspense - "Hydration failed because the initial UI does not match what was rendered on the...
Read more >React Pre-rendering and Potential Hydration Issue
hydrate() explains the cause of my issue: React expects that the rendered content is identical between the server and the client. It can...
Read more >react-hydration-error - Next.js
While rendering your application, there was a difference between the React tree that was pre-rendered (SSR/SSG) and the React tree that rendered during...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Here’s the demo source code https://github.com/adamsoffer/next-apollo-example/tree/f4ea2ffd05e18af15589051ffcbd688d6b8019a1
(visible by visiting https://next-with-apollo.vercel.app/_src)
@adrienpsl just want to further enhance your implementation in case if you hadn’t meet the problem.
if (globalApolloClient && initialState && !hasSetInitialStore)will be executed wheninitalState = {}becauseif ({})is evaluatedtruebut we don’t want to restore the empty state obviously. So the true implementation is to do a true check on empty object such asIt seems like the problem only occurs on the really first render and and then you switch pages from
SSR->SSR-> go back to previous pageSSR. The empty state kicks in and cause the unwanted store.SSRtoCSRback and forth wouldn’t create that empty state; And it only appears on the first time.