Warning: Prop className did not match.
Examples bug report
Example name
Describe the bug
Also posted here: #2538
Using css prop introduced with styled-components v4 causes Warning: Prop className did not match..
To Reproduce
Add any HTML element with css prop.
Expected behavior
Correctly styled rendering on the server side without any warnings.
Screenshots

System information
- OS: Windows
- Chrome
- Version of Next.js: 8.1.0
Additional context
Here is an example I created to demonstrate the issue: https://codesandbox.io/embed/jlwvwyy0ow
Open this and refresh once the building is done: https://jlwvwyy0ow.sse.codesandbox.io/
Happens to me everytime. +1
The same happens with Next v.7. This error doesn't occur when the server starts, only after making changes in the code.
I'm seeing the same error. It doesn't appear to affect the live app, but it's very annoying to have it constantly appearing locally.
I have a similar error, but with inline style.
Warning: Prop `style` did not match. Server: "height:50px;margin-left:4vw;cursor:pointer;width:auto;margin-top:0px" Client: "height:30px;margin-left:4vw;cursor:pointer;width:auto;margin-top:6px"
😢
I hope once enough people raise their voices here this issue will get attention 🙂
I face this issue in my simple navbar active className, is there a workaround until official fix?
Use 👍 on the initial issue instead of "+1" and "same problem".
If you do feel like posting +1 provide a clear and concise reproduction that is clearly reproducible. Otherwise the comment is not actionable.
This goes for any open-source project you're commenting on.
Thanks 🙏
Seems like they fixed latest release this bug https://github.com/styled-components/styled-components/issues/2563
Nope, that's a totally different log message, it is the one with yellow background on the screenshot I posted, it disappeared after the update.
First one, warning about different classNames is still there.
Tagging this as up for grabs to investigate by a motivated contributor.
Hey there, please update babel-plugin-styled-components to the latest version which should fix css prop mismatches: https://github.com/styled-components/babel-plugin-styled-components/releases/tag/v1.10.1
I've noticed an error message in development still, but no ill effects from it so can be safely ignored.
Still same after fix posted above, and can't ignore it. Having some layout problems when this error occurs.
So do I, when this occurs I'm getting layout errors and my component go into a weird state where they do not render based on new props.
It happens for me in an inline style.
Make sure your babel plugin version is up to date, lots of fixes in the last couple weeks. We also made changes to how we do dev styles in v5 that largely address this issue
The Prop 'style' does not match is not solved with the babel plugin upgrade.
"style" is an inline style and nothing to do with styled-components, so that's a totally separate issue
what's the fix for this one? i always get this warning everytime i refresh. i always do refresh everytime change something, bad old habit 😅 everytime i do refresh it shows warning and the styling all gone
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 side rendered style client generates it by itself.
edit: I just downloaded the example and couldn't reproduce the issue while using the same code as in your codepen sandbox. Tested in chrome and firefox and it behaves the same (no error nor warning).
@jass-trix have you tried the s-c v5 beta? We made a lot of changes to eliminate this issue.
@probablyup how to use this version?