Open robert-j-webb opened 5 days ago
Note, I am also seeing it on Next 15 canary
installHook.js:1 A tree hydrated but some attributes of the server rendered HTML didn't match the client properties. This won't be patched up. This can happen if a SSR-ed Client Component used:
- A server/client branch `if (typeof window !== 'undefined')`.
- Variable input such as `Date.now()` or `Math.random()` which changes each time it's called.
- Date formatting in a user's locale which doesn't match the server.
- External changing data without sending a snapshot of it along with the HTML.
- Invalid HTML tag nesting.
It can also happen if the client has a browser extension installed which messes with the HTML before React loaded.
https://react.dev/link/hydration-mismatch
...
<HotReload assetPrefix="">
<ReactDevOverlay onReactError={function} state={{nextId:1, ...}} dispatcher={{...}}>
<DevRootNotFoundBoundary>
<NotFoundBoundary notFound={<NotAllowedRootNotFoundError>}>
<NotFoundErrorBoundary pathname="/" notFound={<NotAllowedRootNotFoundError>} notFoundStyles={undefined} ...>
<RedirectBoundary>
<RedirectErrorBoundary router={{...}}>
<Head>
<link>
<RootLayout>
<html lang="en" className="[color-sch...">
<body
className={"overflow-y-scroll bg-gray-1100 bg-[url('/grid.svg')] pb-36"}
- style={{}}
>
...
...
Repro case: https://replit.com/@robertwebb10/GSAP-Nextjs-Body-style-error-reprodution?v=1
Repro case, on NextJS 15
Hi, I tracked down the cause of this error in the console:
I'm using NextJS 14.1.2, app router, gsap/react: 2.1.1
The code that causes this error is just:
I wanted to see if I could fix the problem, so I took a look at the source code and found some code that looked like a potential cause.
In the
enable
function, body style is modified twice link to codeI found that if I removed the two lines that modify body style, then the error went away.
So now it becomes:
Now I'm not sure what the suggested fix is. Probably you need to make sure your bounds calculation doesn't occur until after render.
You can wrap client side only checks like this in:
And then it won't run on the server, which is what is causing this error.