Skip to content

Bug: react-is@19 does not recognise elements from React 18 #36409

@SimenB

Description

@SimenB

React version: 18.3.1 / 19.2.5 (both affected)

Steps To Reproduce

  1. Install react@18 and react@19 alongside react-is@19 (using npm package aliases)
  2. Create an element with each React version
  3. Call isElement() from react-is@19 on each element

Link to code example: https://codesandbox.io/p/devbox/f4ch33

The current behavior

react-is@19 returns false for elements created by React 17/18.

React 19 changed $$typeof from Symbol(react.element) to Symbol(react.transitional.element). react-is@19 only checks for the new symbol and does not recognise the old one.

react-is@19 .isElement() on react@19 element: true
react-is@19 .isElement() on react@18 element: false  ← broken

This breaks any tool that upgrades to react-is@19 while its users are still on React 17/18. We hit this in jestjs/jest#15402 - pretty-format's ReactElement plugin silently falls back to printing elements as plain objects.

The expected behavior

react-is@19 should recognise elements created by React 17 and 18. Alternative is what I do in jestjs/jest#16123 (use both react-is@18 and react-is@19) but that feels like an unnecessary burden to place on the community

(Disclaimer - Claude Code wrote the reproduction and this OP 😀)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    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