Prop `className` did not match. Server: "sc-kEYyzF gfWKdx" Client: "sc-ifAKCX cFlEyZ"
See original GitHub issueEnvironment
next: 6.1.1 babel-plugin-styled-components: 1.8.0 styled-components: 3.3.3
.babelrc
{
"presets": [
"next/babel"
],
"plugins": [
[
"babel-plugin-styled-components",
{
"ssr": true,
"displayName": true,
"preprocess": false
}
]
]
}
Expected Behavior
Server and Client style has to be the same
Actual Behavior
The server-side generates the right style. However, the client-side broke down the UI.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Warning: Prop `className` did not match. when using styled ...
That error is showing you the class that is being created by your styled-components library on the server and how it is different...
Read more >Warning: Prop className did not match. #7322 - GitHub
It appears to be an issue that backend generates styled component but client doesn't get it/doesn't use it and instead of using server...
Read more >Fixing ClassName did not match error - DEV Community
Create a file named .babelrc in the root directory and configure it. Here's the config file. { "presets": [ "next/babel" ], "plugins": ...
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 >Warning: Prop className did not match | By Arbaoui mehdi
Prop className did not match " which caused mainly by a styling is being rendered on the client dynamically and the "./pages/_app.js" was ......
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
If they’re different with the babel plugin on and ssr mode enabled, your code likely has different behavior on the server vs client. In general, it’s best to put client-specific enhancements in
componentDidMount
rather than at construction time so rehydration is not affected.Some code smells to search for:
typeof window !== 'undefined'
,if (process.browser)
The library I used the
create-react-app
to develop and then published it, I run script to compile from ES6 => ES5.Then in the main site, I used
next.js
and install thelibrary
. The issue happens there.