Skip to content

fix(react-is): support legacy React elements (react.element)#36420

Open
Liuwei1125 wants to merge 1 commit intofacebook:mainfrom
Liuwei1125:fix/react-is-legacy-element
Open

fix(react-is): support legacy React elements (react.element)#36420
Liuwei1125 wants to merge 1 commit intofacebook:mainfrom
Liuwei1125:fix/react-is-legacy-element

Conversation

@Liuwei1125
Copy link
Copy Markdown

Bug Fix Summary

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

Problem

React 19 changed $$typeof from Symbol('react.element') to Symbol('react.transitional.element'). The react-is@19 package only checks for the new symbol, breaking backward compatibility with React 17/18 elements.

Solution

Update isElement() and typeOf() in packages/react-is/src/ReactIs.js to also recognize REACT_LEGACY_ELEMENT_TYPE.

Changes

  1. ReactIs.js: Import REACT_LEGACY_ELEMENT_TYPE and add it to:

    • typeOf() switch statement
    • isElement() check
  2. ReactIs-test.js: Add test case should identify legacy elements from older React versions

Testing

// Before fix
reactIs.isElement(react18Element) // false

// After fix
reactIs.isElement(react18Element) // true

This fix ensures tools that upgrade to react-is@19 (like jest's pretty-format) can still identify elements created by React 17/18 without requiring users to upgrade React.

React 19 changed $$typeof from Symbol('react.element') to
Symbol('react.transitional.element'). The react-is package only
checked for the new symbol, breaking backward compatibility with
React 17/18 elements.

This fix updates isElement() and typeOf() to also recognize
REACT_LEGACY_ELEMENT_TYPE, ensuring tools that upgrade to react-is@19
can still identify elements created by older React versions.

Fixes facebook#36409
Closes facebook#36409
@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented May 6, 2026

Hi @Liuwei1125!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@Liuwei1125
Copy link
Copy Markdown
Author

I have signed the Meta CLA. Please re-check.

@meta-cla meta-cla Bot added the CLA Signed label May 6, 2026
@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented May 6, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant