Console error: Prop `className` did not match
See original GitHub issueGreetings,
The following error shows up but only when using Safari browser (not able to reproduce on Chrome)
Warning: Prop `className` did not match. Server: "css-b8ldur-Input" Client: "css-19odofu-Promise"
React: 16.8.6 React-select: v4.1 @emotion/cache: “^11.0.0” @emotion/react: “^11.1.1”
Mac OSX Safari v: 13.1.3
Code sandbox with reproducible error: https://codesandbox.io/s/react-ssr-bug-hfp29?file=/src/components/App.jsx
First reported here: https://github.com/JedWatson/react-select/issues/3590#issuecomment-777972174
Issue Analytics
- State:
- Created 3 years ago
- Reactions:18
- Comments:7 (4 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
This error doesn't occur when the server starts, only after making changes in the code. 68
Read more >Fixing ClassName did not match error - DEV Community
Warning: Prop `className` did not match. ... This is probably one of the most annoying problem with Next.js, Typescript and styled-component ...
Read more >Prop `className` did not match - CodeSandbox
This Sandbox is running an experiment. You have to fork it before you can make any changes. Fork. VS Code's tsserver was deleted...
Read more >Prop `className` did not match. Server: "css-1l1ns9g ...
I am using ACE/react and receiving an error in the chrome developer console that I really do not understand:
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
@Methuselah96 I would accept a PR removing this code temporarily, It would be also great if we could gather example stack traces from different browsers so we could write tests for this label extraction.
There is some code in React which does a similar thing - we might want to take a look at this to see if we could leverage a similar logic: https://github.com/facebook/react/pull/18561/files#diff-116ca25b733347b0a69576d788fdad10eb9e5d118a7f26f0cbd0afb2eedb2bfdR31
I was able to narrow down the problem a little bit. This is related to https://github.com/emotion-js/emotion/issues/1462 (and likely the issue described here).
The code in question is https://github.com/emotion-js/emotion/blob/676a92631ef9c35cfd9f8660cce58aa0f7781528/packages/react/src/emotion-element.js#L40-L55
The issue seems to be that on Safari the name of the component is not present in the stack trace. Here are the relevant snippets from example stack traces:
Chrome:
Firefox:
Safari:
The CodeSandbox provided in the original description still reproduces this issue. Additionally, here’s a Next.js repo that also exhibits the problem: https://github.com/Methuselah96/nextjs-blog
@Andarist Can your provide input on whether there are any potential solutions or workarounds we can pursue or if there is a plan to get this resolved? This is impacting quite a few people using
react-select
(https://github.com/JedWatson/react-select/issues/3590, https://github.com/JedWatson/react-select/issues/4706, https://github.com/JedWatson/react-select/issues/3124, etc.). Let me know if there’s any other information I can provide. Thanks!