Skip to content
Discussion options

You must be logged in to vote

The most common cause of issues when using styled-components in a component library is multiple instances of the library being bundled. Ensure that:

  1. styled-components is a peerDependency in your library (which you have)
  2. Your library build does not bundle styled-components — mark it as external in your bundler config
  3. The consuming app has only one copy installed — run npm ls styled-components to verify
  4. If using the Babel plugin in the consuming app, the displayName and component IDs generated at build time must be deterministic and not conflict with the ones baked into the library

For SSR with Next.js, the consuming app needs its own styled-components registry setup regardless of the lib…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by quantizor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants