Skip to content

Styled class name vary in Server vs Client slide when using in next js #216

@umakantp

Description

@umakantp

Hi Team,

I created an example using https://github.com/vercel/next.js/tree/canary/examples/with-styled-components with bootstrap-styled.

I created few components using components from bootstrap-styled as follows:

import {Button} from '@bootstrap-styled/v1'

const Btn = () =>  (<Button>Demo</Button>)

export default Btn

Now when I consume/use this Btn component. It throws errors in console as follows:

react-dom.development.js?a814:67 Warning: Prop `className` did not match. Server: "Button-h8watj-0 hcRYRl btn btn-primary" Client: "sc-pNWdM ddwWoV btn btn-primary"
    at button
    at ButtonUnstyled (webpack-internal:///../../node_modules/@bootstrap-styled/v4/dist/@bootstrap-styled/v4.esm.js:3052:5)
    at O (webpack-internal:///../../node_modules/styled-components/dist/styled-components.browser.esm.js:31:19450)
    at div
    at O (webpack-internal:///../../node_modules/styled-components/dist/styled-components.browser.esm.js:31:19450)
    at div
    at ContainerUnstyled (webpack-internal:///../../node_modules/@bootstrap-styled/v4/dist/@bootstrap-styled/v4.esm.js:14740:5)
    at O (webpack-internal:///../../node_modules/styled-components/dist/styled-components.browser.esm.js:31:19450)
    at header
    at O (webpack-internal:///../../node_modules/styled-components/dist/styled-components.browser.esm.js:31:19450)
    at HeaderComponent (webpack-internal:///./src/views/common/header/header.js:37:24)

If we carefully see, When rendering from service side, styled component uses component name/display name as prefix in class name i.e. Button-. When it renders on client it doesn't use Button (instead uses sc-)

I have followed the all the guidelines of styled components + bootstrap styled as per doc. Any pointers what could be the issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions