Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permit non-DEV Elements in React.Children w/ DEV #32117

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yungsters
Copy link
Contributor

Summary

As mentioned in #29662 (comment), the key validation when using React.Children does not currently support non-DEV elements in DEV. This minor fix preserves support for these use cases.

How did you test this change?

$ yarn test ReactChildren-test.js

@react-sizebot
Copy link

react-sizebot commented Jan 18, 2025

Comparing: ddc26c9...f7a4b91

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB +0.11% 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 514.24 kB 514.24 kB = 91.74 kB 91.74 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB +0.11% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 557.28 kB 556.18 kB = 98.97 kB 98.72 kB
facebook-www/ReactDOM-prod.classic.js = 595.79 kB 595.79 kB = 104.85 kB 104.85 kB
facebook-www/ReactDOM-prod.modern.js = 586.21 kB 586.21 kB = 103.30 kB 103.30 kB
facebook-www/ReactFreshRuntime-dev.classic.js = 13.82 kB 12.37 kB = 3.19 kB 2.99 kB
facebook-www/ReactFreshRuntime-dev.modern.js = 13.82 kB 12.37 kB = 3.19 kB 2.99 kB
oss-experimental/react-refresh/cjs/react-refresh-runtime.development.js = 13.80 kB 12.36 kB = 3.18 kB 2.98 kB
oss-stable-semver/react-refresh/cjs/react-refresh-runtime.development.js = 13.80 kB 12.36 kB = 3.18 kB 2.98 kB
oss-stable/react-refresh/cjs/react-refresh-runtime.development.js = 13.80 kB 12.36 kB = 3.18 kB 2.98 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js = 480.90 kB 479.78 kB = 76.64 kB 76.42 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js = 427.88 kB 426.76 kB = 68.85 kB 68.61 kB
oss-experimental/react-art/cjs/react-art.production.js = 322.55 kB 321.51 kB = 54.86 kB 54.63 kB
oss-experimental/react/cjs/react.development.js = 46.15 kB 45.86 kB = 10.53 kB 10.48 kB
oss-experimental/react/cjs/react.production.js = 18.42 kB 18.13 kB = 4.77 kB 4.71 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.development.js = 32.24 kB 31.60 kB = 5.77 kB 5.69 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.development.js = 32.24 kB 31.60 kB = 5.77 kB 5.69 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.development.js = 32.24 kB 31.60 kB = 5.77 kB 5.69 kB
oss-experimental/react-debug-tools/cjs/react-debug-tools.production.js = 28.72 kB 28.15 kB = 5.64 kB 5.56 kB
oss-stable-semver/react-debug-tools/cjs/react-debug-tools.production.js = 28.72 kB 28.15 kB = 5.64 kB 5.56 kB
oss-stable/react-debug-tools/cjs/react-debug-tools.production.js = 28.72 kB 28.15 kB = 5.64 kB 5.56 kB
facebook-www/ReactFreshRuntime-dev.classic.js = 13.82 kB 12.37 kB = 3.19 kB 2.99 kB
facebook-www/ReactFreshRuntime-dev.modern.js = 13.82 kB 12.37 kB = 3.19 kB 2.99 kB
oss-experimental/react-refresh/cjs/react-refresh-runtime.development.js = 13.80 kB 12.36 kB = 3.18 kB 2.98 kB
oss-stable-semver/react-refresh/cjs/react-refresh-runtime.development.js = 13.80 kB 12.36 kB = 3.18 kB 2.98 kB
oss-stable/react-refresh/cjs/react-refresh-runtime.development.js = 13.80 kB 12.36 kB = 3.18 kB 2.98 kB

Generated by 🚫 dangerJS against 3300307

@smeng9
Copy link

smeng9 commented Jan 18, 2025

Thanks for adding the test case!

@smeng9
Copy link

smeng9 commented Jan 21, 2025

Hi I have fixed the linter issue of for ... of ... in the test case in #32061

Hope we can get this merged soon

@smeng9
Copy link

smeng9 commented Jan 23, 2025

Hi @yungsters ,

The CI pipeline has issues regarding gated tests should fail but passed. We are now providing a valid test case that should pass. Shall we remove the gate comment?

@@ -1039,6 +1039,32 @@ describe('ReactChildren', () => {
});
});

// @gate __DEV__
Copy link

Choose a reason for hiding this comment

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

I removed this line in my latest commit a7b0192 as it should work for both dev and prod

Comment on lines +1050 to +1054
Object.entries(source).forEach(([key, value]) => {
if (key !== '_owner' && key !== '_store') {
productionElement[key] = value;
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

The way this test case needs to be contrived signals that this mix of environments should really not be supported. We could consider adding build types to the version checks to prevent apps from relying on these setups in the future.

Copy link
Collaborator

@eps1lon eps1lon Jan 24, 2025

Choose a reason for hiding this comment

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

I'd expect you encounter this in development when you use 3rd party libraries that only have a single entrypoint with JSX compiled for production. Would require a lot of heavy lifting if we require libraries to ship both dev and prod entrypoints.

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.

6 participants