warning prop classname did not match. server material-ui & next js
See original GitHub issueWarning: Prop className did not match. Server: "MuiButtonBase-root MuiListItem-root MuiListItem-gutters MuiListItem-button css-rmvemx-MuiButtonBase-root-MuiListItem-root" Client: "MuiButtonBase-root MuiListItem-root MuiListItem-gutters MuiListItem-button Mui-selected css-rmvemx-MuiButtonBase-root-MuiListItem-root"
I know that the react error has to do with what it generates on the server vs what is generated on the client, it hopes that ideally they are the same, but I don’t know why it is not and how to solve it.
I base myself on the installation of the example proposed by material-ui https://github.com/mui-org/material-ui/tree/next/examples/nextjs
This is my package.json file
"dependencies": {
"@emotion/cache": "^11.4.0",
"@emotion/react": "^11.4.0",
"@emotion/server": "^11.4.0",
"@emotion/styled": "^11.3.0",
"@material-ui/core": "^5.0.0-alpha.35",
"@material-ui/icons": "^4.11.2",
"@material-ui/styles": "^4.11.4",
"moment": "^2.29.1",
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2"
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:15 (10 by maintainers)
Top Results From Across the Web
React + Material-UI - Warning: Prop className did not match
The problem is the SSR rendering in Next.js, which produces the style fragment before the page is rendered. Using Material UI and Next.js...
Read more >Prop `className` did not match. Server generate classes ID ...
Material Ui 5 version has problem with SSR Here is error: Warning: Prop className did not match. Server generate classes ID difference than ......
Read more >Fixing ClassName did not match error - DEV Community
Warning : Prop `className` did not match. Server: Client: This is probably one of the most annoying problem with ...
Read more >React + Material-UI - Warning: Prop className did not match ...
The problem is the SSR rendering in Next.js, which produces the style fragment before the page is rendered. Using Material UI and Next.js...
Read more >Solving the Styled Components Warning in Next.JS with Babel
Warning : Prop `className` did not match. Server: “fs-fdsf” Client: “sd-dfasj”. The combination of Next.JS and Styled Components is truly ...
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 FreeTop 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
Top GitHub Comments
@oliviertassinari thanks I need to investigate further, I think as I have a SSG rendered page and one of my components is depending on user auth maybe thats where the problem relies. I might have to wait and re-hydrate differently. The issue just raised on upgrading NextJS and webpack so maybe the issue just got triggered through that upgrades. This might be the relevant issue which needs to be checked https://github.com/vercel/next.js/issues/26184#issuecomment-864083198
@oliviertassinari I could give you access to my repo if you want a quick reproduction. You would only need to pull it and set a few env variables to reproduce. 1 minute long job.