Skip to content

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

@marzelc

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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions