Fix parameters or JSX dev runtime#3880
Merged
Merged
Conversation
* There was a parameter missing (`isStaticChildren: boolean`), which is not useful\*, but is still being passed * Fix order of `source` and `self` again (incorrectly introduced in GH-3459) * Fix some (internal JSDoc) types for these parameters My guess is that the previous PR “fixed” the earlier problem because `self` isn’t used, so by calling `isStaticChildren` “`self`”, a bug went away. The source for where this `jsxDEV` call is generated in Babel is here: <https://github.com/babel/babel/blob/3952486/packages/babel-plugin-transform-react-jsx/src/create-plugin.ts#L506-L508>. The React RFC for the transform that mentions the dev runtime is here: <https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md#dev-only-transforms> \* `isStaticChildren` is the same as whether `jsxs` would be used, instead of `jsx`. Which is also whether there are 2 or more children passed: * `<a />` -> `jsx('a', {})` * `<a>b</a>` -> `jsx('a', {children: 'b'})` * `<a>{1}{2}</a>` -> `jsxs('a', {children: [1, 2]})` Related-to: GH-3459.
Contributor
Author
|
/cc @marvinhagemeister and @JoviDeCroock who worked on / reviewed the previous PR! |
JoviDeCroock
approved these changes
Feb 3, 2023
Member
|
@wooorm thank you for all the pointers, made it much easier to review this! |
Member
|
@wooorm Good catch, that's on me for messing up the arguments. Thank you so much for filing a PR! |
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.
isStaticChildren: boolean), which is not useful*, but is still being passedsourceandselfagain (incorrectly introduced in Fix swapped jsx runtime__sourceand__selfarguments #3459)My guess is that the previous PR “fixed” the earlier problem because
selfisn’t used, so by callingisStaticChildren“self”, a bug went away.The source for where this
jsxDEVcall is generated in Babel is here: https://github.com/babel/babel/blob/3952486/packages/babel-plugin-transform-react-jsx/src/create-plugin.ts#L506-L508.The React RFC for the transform that mentions the dev runtime is here: https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md#dev-only-transforms.
React’s implementation is here: https://github.com/facebook/react/blob/855b77c9bbee347735efcd626dda362db2ffae1d/packages/react/src/jsx/ReactJSXElementValidator.js#L306-L311
*
isStaticChildrenis the same as whetherjsxswould be used, instead ofjsx. Which is also whether there are 2 or more children passed:<a />->jsx('a', {})<a>b</a>->jsx('a', {children: 'b'})<a>{1}{2}</a>->jsxs('a', {children: [1, 2]})Related-to: GH-3459.