-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 in development for Next.js app with MUI Material v5 after updating emotion dependencies #3222
Comments
same here, we need it to be fixed. |
I need a runnable repro case to investigate this. |
I can get that over to you tomorrow. |
I'd appreciate that, thanks! |
interestingly, when I shrink the project to bare minimum, the issue is gone, I will need to do more research. |
FWIW, I am getting this problem with: "@emotion/cache": "11.11.0",
"@emotion/react": "11.11.4",
"@emotion/styled": "11.11.5", |
I think this is introduced as an issue with this change. The server now defaults to using It doesn't seem reasonable to assume that users will know to add Setting an override in my
|
@mridgway I can confirm I have this issue even with 1.2.0
|
This is news to me. I totally considered this a stable feature. It's mentioned multiple times in other parts of the docs and is never guarded with the experimental warning at those places. On top of that, node.js doesn't emit any experimental features warnings when you use custom conditions so it's not apparent at all that it's experimental. That said, I don't know how we are supposed to deal with this. The environment needs to be in a cohesive state. What kind of setup are you using? Is your server created manually? |
I can confirm that the override works for me, after override it back to 1.2.0, and redo npm install, the warning is gone. |
I think this is a red herring. My current version of code uses "@emotion/cache": "11.11.0",
"@emotion/react": "11.11.4",
"@emotion/styled": "11.11.5", |
Using MUI Material v5 with Nextjs Pages router and got this exact problem after updating emotion dependencies. While I don't have |
Once I get the repro case of the problem, I could investigate this |
As an additional data point, I've been seeing these errors since MUI |
Is there a way to actually fix it without overriding dependencies and downgrading packages? |
Current behavior:
We are getting hydration errors in development on pages that render components which are styled MUI components, after updating the following dependencies:
@emotion/cache
from11.11.0
to11.13.0
@emotion/react
from11.11.4
to11.13.0
@emotion/styled
from11.11.5
to11.13.0
Notably, we did not update MUI or any related dependencies at the same time.
It only affects components created using the
styled
helper, e.g.:It seems to be a problem with one of those packages' underlying dependencies, because the issue disappears when we use the old
package-lock.json
, but not if we nuke and recreate it.I've been trying to identify the root cause but I'm finding it difficult, I'm not very familiar with the internals of emotion. I think it could be a problem with the serialiser, because the client
<style>
tags being inserted look to me like thedata-emotion
attributes are missing the serialized classnames that typically seem to follow the cache prefixmui
, e.g.:It could also be a problem with the
hash
package, since the hashed part of the className is different.The issue is not present in production builds of the app.
To reproduce:
CSB: TODO later if I have some more time
Expected behavior:
Classnames should match on both client & server, no hydration errors.
Environment information:
The text was updated successfully, but these errors were encountered: