Skip to content

Comments

chore: add dev warning for deprecated fragment flattening#4277

Open
amanabiy wants to merge 5 commits intomainfrom
chore/add-fragment-deprecation-warning
Open

chore: add dev warning for deprecated fragment flattening#4277
amanabiy wants to merge 5 commits intomainfrom
chore/add-fragment-deprecation-warning

Conversation

@amanabiy
Copy link
Member

@amanabiy amanabiy commented Feb 20, 2026

Description

This PR inlines the library react-keyed-flatten-children@^2.2.1 and adds react-is: ^18.2.0 to package.json (the version for react-is was checked against the one used by react-keyed-flatten-children from here). And, it adds dev warning when fragments are being flattened.

Tested by: Running through my pipeline and running Dry Run Build

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.

@amanabiy amanabiy requested a review from a team as a code owner February 20, 2026 14:12
@amanabiy amanabiy requested a review from pan-kot February 20, 2026 14:12
@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.42%. Comparing base (5cfcc6d) to head (a66c2e7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4277   +/-   ##
=======================================
  Coverage   97.42%   97.42%           
=======================================
  Files         891      892    +1     
  Lines       26098    26102    +4     
  Branches     9435     9434    -1     
=======================================
+ Hits        25426    25430    +4     
- Misses        629      666   +37     
+ Partials       43        6   -37     

☔ 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.


export function flattenChildren(children: ReactNode, componentName?: string): ReactNode[] {
const versionString = React.version?.split('.')[0];
const majorVersion = versionString ? parseInt(versionString, 10) : NaN;
Copy link
Member

@pan-kot pan-kot Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would extract React version getter into a util

return Children.toArray(children).reduce((acc: ReactNode[], node, nodeIndex) => {
if (isFragmentWithChildren(node)) {
if (componentName) {
warnOnce(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a test for that

);
});

it('does not warn when no componentName is provided', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a use case for calling the util w/o component name?

Copy link
Member Author

@amanabiy amanabiy Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we use it in pages/flashbar/runtime-content.page.tsx here

@amanabiy amanabiy requested a review from pan-kot February 23, 2026 15:53
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.

2 participants