Skip to content

emotion style does not work when using renderToString in React18 #2906

Description

@vmaerten

Current behavior:

With React 18 (works in React 17), when we use ReactDOMServer.renderToString(EMOTION_COMPONENT) the style is not injected in the head.

To reproduce:

  1. Open this Sandbox: https://codesandbox.io/s/bug-rendertostring-with-react-18-7ty15q

Expected behavior:

Div BlockColorGreen should be green but no style is applied (class is present but no style injected)

Works fine with React 17, please see: https://codesandbox.io/s/not-bug-rendertostring-with-react-17-04vtp2

Environment information:

  • react version: 18.0.0
  • react-dom version: 18.0.0
  • @emotion/react version: 11.9.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions