Skip to content

fix: Inline isFragment function to remove react-is dependency#4220

Open
amanabiy wants to merge 3 commits intomainfrom
dev-v3-amanabiy-inline-isFragment
Open

fix: Inline isFragment function to remove react-is dependency#4220
amanabiy wants to merge 3 commits intomainfrom
dev-v3-amanabiy-inline-isFragment

Conversation

@amanabiy
Copy link
Member

@amanabiy amanabiy commented Feb 3, 2026

Description

This PR inlines the isFragment function in the internal vendored react-keyed-flatten-children implementation to completely eliminate the react-is dependency. This builds on PR #3997.

Why?

React 19 renamed the element symbol from react.element to react.transitional.element to detect version mismatches in React and react-is (React PR #28813). This means we can't use react-is if we want to support both React 19 and maintain backward compatibility. Therefore, we need to replace the isFragment function with an internal implementation to make it work with both forward and backward compatibility.

Here is a minimal example of the problem using sandbox

Changes

It makes it easy for review if you go through the commits

  • The first commit reverses this PR #3997
  • The second commit makes this isFragment inline removing react-is
  • The third commit adds bigint support to handle bigint as a valid child type for React 19 compatibility (React PR #24580). TypeScript will error on bigint children with React <19 before reaching this conditional statement.

How I tested it:

  • Verified across multiple React versions from 16 to 19 using a simple application to test the flatten works as expected.

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.18%. Comparing base (e494891) to head (50f72ca).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4220   +/-   ##
=======================================
  Coverage   97.18%   97.18%           
=======================================
  Files         883      883           
  Lines       25870    25870           
  Branches     9347     9347           
=======================================
  Hits        25141    25141           
  Misses        682      682           
  Partials       47       47           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant