Next.js Discord

Discord Forum

Help fixing hydration errors on Next.js app with React Compiler

Answered
Frank posted this in #help-forum
Open in Discord
In an attempt to find hydration errors I basically commented out the entire app from the /create route and yet this console error still exists:

hook.js:608 A tree hydrated but some attributes of the server rendered HTML didn't match the client properties. This won't be patched up.


Then the log spits out pretty much the entire app DOM tree. How does one go about diagnosing this? There is nothing useful in Terminal, and I thought commenting out parts of the app would at least get me directionally pointed to where to find this. Thought? 😅
Answered by Frank
Removing React Compiler fixed the hydration errors. 🤷🏻
View full answer

7 Replies

I don't mind sharing the code, here is the [branch and file I am looking at](https://github.com/caoimghgin/prismcolor.io/blob/feature-react-compiler/pages/create.tsx). I didn't commit the commented out section but you get the gist from the screenshot of what I was trying to do.

What other context can I provide?
Asian black bear
The diff shows you the class names are not stable between client and server. Since they are prefixed with sc it looks like something in the context of styled components or your Mantine setup seeing you reference those. Try investigating in that direction.
oOoo I didn't realize that was a diff. I see the + and - now. Thank you for helping me see that Near.
Ugh. Still not really able to isolate this yet. I went to the Manatee Discord to ask if this was a Mantee thing. In NavBar I commented out everything and it's still not clear to me what about this styled-component that's left would cause a hydration error.
I got further here realizing styled-components wasn't set up correctly for Next.js [so I went through these docs to set it up correctly](https://nextjs.org/docs/app/building-your-application/styling/css-in-js#styled-components). I got the app back up and running again, fixed a transient prop issue, but am still running into this hydration error. I also talked to the Manatee team and they said it's not related to them.

From the diff, it looks like it's coming [from NarBar.tsx](https://github.com/caoimghgin/prismcolor.io/blob/feature-react-compiler/components/NavBar/NavBar.tsx#L11) but I am stuck again understanding how to fix these hydration errors.
Removing React Compiler fixed the hydration errors. 🤷🏻
Answer