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.

SSR classNames not matching when using Style Object

See original GitHub issue

Hello,

I’m integrating react-select to my SSR implementation, and currently I’m having issues with classNames not matching:

Warning: Prop className did not match. Server: “css-1u7qna3” Client: “css-6xc8cw”

My Select declaration is as follows:


<Select
    instanceId={this.props.elementConfig.name}
    value={selectedOption}
    onChange={this.handleChange}
    options={options}
    styles={customStyles}
    className='Occupation'
    classNamePrefixunion='Option--'
/>

The problem seems to happen when I try to use the styling object, as per the documentation below:

https://react-select.com/styles

I was wondering if someone else has experienced this issue and would care to help.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:17
  • Comments:12

github_iconTop GitHub Comments

24reactions
bmsuseludacommented, Jun 11, 2019

The instanceId doesn’t fix it for me.

<ReactSelect
        instanceId={label}
        className={styles.dropdown}
        classNamePrefix="pcc-dropdown"
        options={options}
        value={value}
        defaultValue={defaultValue}
        isLoading={isLoading}
        isDisabled={isDisabled}
        onChange={handleOnChange}
        placeholder={placeholder}
        components={{ DropdownIndicator, Menu }}
        isSearchable={false}
        ariaLabel={label}
      />

Without instanceId i’m getting the error: Warning: Prop id did not match. Server: "react-select-24-input" Client: "react-select-2-input"

In another issue i learned that i have to set the instanceId. With id instanceId the prop id warning is away but now i’m getting the className prop warning.

Is there something i’m missing? thanks

11reactions
adamsoffercommented, Dec 12, 2018

I also was having this issue. Giving it an instanceId seemed to fix it for me.

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
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 >
Warning: Prop `className` did not match ~ Material UI css ...
I ended up just using the ServerStyleSheet fix to try to make it agreeable with Material UI's ServerStyleSheets object, and ended up with...
Read more >
Tooling - styled-components
If you do not use this plugin and try to server-side render ... "ssr": false ... enable you to store your styled components...
Read more >
Server Side Rendering - Emotion
The default approach works with streaming and requires no additional ... output will insert a <style> tag above each element with styles for...
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