-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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 errors #45246
Comments
Might be related to #44083 In my case React 18.3 fixes these hydration errors:
I'm probably switching back to Next 12 with React 17 though, not going to use React 18.3 isn't actually fixing the problem, it just supresses the error. The error usually means suboptimal code that has to be wrapped with |
## Issue To address the problem that we introduced in 13.0.7 (#42589) where we thought we could use same implementation `next/dynamic` for both `pages/` and `app/` directory. But it turns out it leads to many problems, such as: * SSR preloading could miss the content, especially with nested dynamic calls * Closes #45213 * Introducing suspense boundary into `next/dynamic` with extra wrapped `<Suspense>` outside will lead to content is not resolevd during SSR * Related #45151 * Closes #45099 * Unexpected hydration errors for suspense boundaries. Though react removed this error but the 18.3 is not out yet. * Closes #44083 * Closes #45246 ## Solution Separate the dynamic implementation for `app/` dir and `pages/`. For `app/` dir we can encourage users to: * Directly use `React.lazy` + `Suspense` for SSR'd content, and `next/dynamic` * For non SSR components since it requires some internal integeration with next.js. For `pages/` dir we still keep the original implementation If you want to use `<Suspense>` with dynamic `fallback` value, use `React.lazy` + `Suspense` directly instead of picking up `next/dynamic` * Closes #45116 This will solve various issue before react 18.3 is out and let users still progressively upgrade to new versions of next.js. ## Bug Fix - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
Data fetching (gS(S)P, getInitialProps), Dynamic imports (next/dynamic)
Link to the code that reproduces this issue
N/A
To Reproduce
I have a couple of components which need to render client-only, eg. components with different layout based on screen width, components displaying stuff like "x seconds ago". For these, I use a helper component rendered at the root:
The
clientMountedAtom
is then used by these components like this:Since updating to the latest version, these components have been causing hydration errors such as:
These components are often used in combination with
dynamic
, so that might also have an influence somehow.Describe the Bug
See above.
Expected Behavior
No hydration errors (as in previous versions).
Which browser are you using? (if relevant)
N/A
How are you deploying your application? (if relevant)
next start
The text was updated successfully, but these errors were encountered: