question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

warning prop classname did not match. server material-ui & next js

See original GitHub issue

alt text

Warning: 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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
dohomicommented, Jun 21, 2021

@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

0reactions
abriginetscommented, Jul 7, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found