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.

Console error: Prop `className` did not match

See original GitHub issue

Greetings,

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

Screen Shot 2021-02-11 at 9 45 07 PM

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:open
  • Created 3 years ago
  • Reactions:18
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Andaristcommented, Sep 13, 2021

@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

2reactions
Methuselah96commented, Sep 12, 2021

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:

Error
    at createEmotionProps (emotion-element-99289b21.browser.esm.js:125)
    at jsx (emotion-react.browser.esm.js:100)
    at SelectContainer (index-4bd03571.esm.js:834)
    at renderWithHooks (react-dom.development.js:14985)
    at mountIndeterminateComponent (react-dom.development.js:17811)
    at beginWork (react-dom.development.js:19049)
    at beginWork$1 (react-dom.development.js:23940)
    ...

Firefox:

createEmotionProps@http://localhost:3000/_next/static/chunks/pages/index.js?ts=1631414103915:1170:17
jsx@http://localhost:3000/_next/static/chunks/pages/index.js?ts=1631414103915:1382:105
SelectContainer@http://localhost:3000/_next/static/chunks/pages/index.js?ts=1631414103915:61128:62
renderWithHooks@http://localhost:3000/_next/static/chunks/main.js?ts=1631414103915:32827:27
mountIndeterminateComponent@http://localhost:3000/_next/static/chunks/main.js?ts=1631414103915:35653:13
beginWork@http://localhost:3000/_next/static/chunks/main.js?ts=1631414103915:36891:16
beginWork$1@http://localhost:3000/_next/static/chunks/main.js?ts=1631414103915:41777:14
...

Safari:

createEmotionProps@http://localhost:3000/_next/static/chunks/pages/index.js?ts=1631414130820:1170:26
jsx@http://localhost:3000/_next/static/chunks/pages/index.js?ts=1631414130820:1382:105
renderWithHooks@http://localhost:3000/_next/static/chunks/main.js?ts=1631414130820:32827:27
mountIndeterminateComponent@http://localhost:3000/_next/static/chunks/main.js?ts=1631414130820:35653:28
beginWork$1@http://localhost:3000/_next/static/chunks/main.js?ts=1631414130820:41777:23
...

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!

Read more comments on GitHub >

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

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