Skip to content

createGlobalStyle stylesheet removed when a second instance unmounts, breaking styles on still-mounted instances #5695

Description

@marzelc

When multiple instances of a component that renders a createGlobalStyle-based component are mounted, unmounting any one of them removes the injected stylesheet entirely — even though other instances are still mounted and still depend on those styles.

Live reproduction: https://codesandbox.io/p/sandbox/sc-global-style-repro-forked-tw9tgn

Environnement:

  • react: 18.3.1
  • styled-components: 6.3.12

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