-
Notifications
You must be signed in to change notification settings - Fork 49.6k
Turn on key spread warning in jsx-runtime for everyone #25697
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
Conversation
This should suggest that the key is put first, not last.
Comparing: e1dd0a2...92daf55 Critical size changesIncludes critical production bundles, as well as any change greater than 2%: Significant size changesIncludes any change greater than 0.2%: Expand to show
|
'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' + |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ...
.
There was a problem hiding this comment.
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.
9e135dc
to
92daf55
Compare
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.