KEMBAR78
Turn on key spread warning in jsx-runtime for everyone by sebmarkbage · Pull Request #25697 · facebook/react · GitHub
Skip to content

Conversation

sebmarkbage
Copy link
Collaborator

This improves the error message a bit and ensures that we recommend putting the key first, not last, which ensures that the faster jsx-runtime is used.

This only affects the modern "automatic" JSX transform.

@sizebot
Copy link

sizebot commented Nov 16, 2022

Comparing: e1dd0a2...92daf55

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.min.js = 153.64 kB 153.64 kB = 48.90 kB 48.90 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 155.56 kB 155.56 kB = 49.51 kB 49.51 kB
facebook-www/ReactDOM-prod.classic.js = 530.41 kB 530.41 kB = 94.67 kB 94.67 kB
facebook-www/ReactDOM-prod.modern.js = 515.66 kB 515.66 kB = 92.49 kB 92.49 kB
facebook-www/ReactDOMForked-prod.classic.js = 530.41 kB 530.41 kB = 94.67 kB 94.67 kB
facebook-react-native/react/cjs/JSXDEVRuntime-dev.js +3.19% 35.79 kB 36.93 kB +2.60% 10.33 kB 10.60 kB
facebook-react-native/react/cjs/JSXRuntime-dev.js +3.14% 36.39 kB 37.53 kB +2.58% 10.51 kB 10.78 kB
oss-experimental/react/cjs/react-jsx-dev-runtime.development.js +2.29% 41.74 kB 42.69 kB +1.94% 12.25 kB 12.49 kB
oss-stable-semver/react/cjs/react-jsx-dev-runtime.development.js +2.28% 41.76 kB 42.71 kB +1.94% 12.25 kB 12.49 kB
oss-stable/react/cjs/react-jsx-dev-runtime.development.js +2.28% 41.76 kB 42.71 kB +1.94% 12.25 kB 12.49 kB
oss-experimental/react/cjs/react-jsx-runtime.development.js +2.25% 42.33 kB 43.29 kB +1.94% 12.42 kB 12.67 kB
oss-stable-semver/react/cjs/react-jsx-runtime.development.js +2.25% 42.36 kB 43.31 kB +1.94% 12.43 kB 12.67 kB
oss-stable/react/cjs/react-jsx-runtime.development.js +2.25% 42.36 kB 43.31 kB +1.94% 12.43 kB 12.67 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-react-native/react/cjs/JSXDEVRuntime-dev.js +3.19% 35.79 kB 36.93 kB +2.60% 10.33 kB 10.60 kB
facebook-react-native/react/cjs/JSXRuntime-dev.js +3.14% 36.39 kB 37.53 kB +2.58% 10.51 kB 10.78 kB
oss-experimental/react/cjs/react-jsx-dev-runtime.development.js +2.29% 41.74 kB 42.69 kB +1.94% 12.25 kB 12.49 kB
oss-stable-semver/react/cjs/react-jsx-dev-runtime.development.js +2.28% 41.76 kB 42.71 kB +1.94% 12.25 kB 12.49 kB
oss-stable/react/cjs/react-jsx-dev-runtime.development.js +2.28% 41.76 kB 42.71 kB +1.94% 12.25 kB 12.49 kB
oss-experimental/react/cjs/react-jsx-runtime.development.js +2.25% 42.33 kB 43.29 kB +1.94% 12.42 kB 12.67 kB
oss-stable-semver/react/cjs/react-jsx-runtime.development.js +2.25% 42.36 kB 43.31 kB +1.94% 12.43 kB 12.67 kB
oss-stable/react/cjs/react-jsx-runtime.development.js +2.25% 42.36 kB 43.31 kB +1.94% 12.43 kB 12.67 kB
facebook-www/JSXDEVRuntime-dev.modern.js +1.72% 45.73 kB 46.52 kB +1.35% 12.98 kB 13.16 kB
facebook-www/JSXDEVRuntime-dev.classic.js +1.72% 45.73 kB 46.52 kB +1.35% 12.98 kB 13.16 kB
facebook-react-native/react/cjs/React-dev.js +0.98% 116.87 kB 118.01 kB +0.90% 30.89 kB 31.17 kB
facebook-www/React-dev.modern.js +0.62% 126.94 kB 127.73 kB +0.55% 33.65 kB 33.84 kB
facebook-www/React-dev.classic.js +0.61% 128.04 kB 128.82 kB +0.54% 33.89 kB 34.08 kB

Generated by 🚫 dangerJS against 92daf55

'Explicitly pass a key after spreading props in your JSX call. ' +
'E.g. <Child {...props} key={key} />',
'Warning: An props object containing a "key" prop is being spread into JSX:\n' +
' let props = {key: ...};\n' +
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's do key: someKey to avoid using ... both as syntax and a placeholder?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a non-trivial change in the code but I'll try.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, maybe it doesn't make sense. Because it still writes out the other properties with ....

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I put the key in the front even if that's not the regular order and kept ... for other props.

@sebmarkbage sebmarkbage merged commit 07f46ec into facebook:main Nov 16, 2022
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.

4 participants