Skip to content

Themes not working with styled-components #1416

@robertvansteen

Description

@robertvansteen

I was running in to issues with next.js and styled-components for a big project, and in an attempt to try and isolate the problem I've cloned the styled-component example in the repo and added a simple theme, immediately I saw the issue. While the server renders the component fine, on the client the style disappears and React throws the famous warning Warning: React attempted to reuse markup in a container but the checksum was invalid.

I've created a repository to demonstrate this issue.
https://github.com/rovansteen/next-js-styled-components

All I basically did was replace the hardcoded color: red to color: ${props => props.theme.color}

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