Turn on key spread warning in jsx-runtime for everyone#25697
Merged
sebmarkbage merged 3 commits intofacebook:mainfrom Nov 16, 2022
Merged
Turn on key spread warning in jsx-runtime for everyone#25697sebmarkbage merged 3 commits intofacebook:mainfrom
sebmarkbage merged 3 commits intofacebook:mainfrom
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
|
gaearon
reviewed
Nov 16, 2022
gaearon
reviewed
Nov 16, 2022
| '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' + |
Collaborator
There was a problem hiding this comment.
Let's do key: someKey to avoid using ... both as syntax and a placeholder?
Contributor
Author
There was a problem hiding this comment.
It's a non-trivial change in the code but I'll try.
Contributor
Author
There was a problem hiding this comment.
Well, maybe it doesn't make sense. Because it still writes out the other properties with ....
Contributor
Author
There was a problem hiding this comment.
I put the key in the front even if that's not the regular order and kept ... for other props.
9e135dc to
92daf55
Compare
gaearon
approved these changes
Nov 16, 2022
12 tasks
This was referenced May 17, 2024
This was referenced Nov 10, 2024
This was referenced Nov 10, 2024
This was referenced Nov 10, 2024
This was referenced Nov 11, 2024
This was referenced Nov 11, 2024
This was referenced Nov 11, 2024
This was referenced Nov 12, 2024
This was referenced Nov 12, 2024
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This improves the error message a bit and ensures that we recommend putting the key first, not last, which ensures that the faster
jsx-runtimeis used.This only affects the modern "automatic" JSX transform.