-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
JSX Spec has been updated (Fragment syntax) #19094
Comments
Thanks for actually providing an explanation @Kovensky! I'll note that the author also elaborated here as well. |
Just wanted to point out that since comments are treated as whitespace in Javascript, they're also allowed between
|
Sounds good. A few questions:
|
@RyanCavanaugh I think I can answer a few of those:
Yup.
Yup. |
Preserve Maybe EDIT: Preserving |
I think the |
Would a |
Referencing facebook/jsx#94 here so I don't forget about it. :) |
The JSX spec has been updated to support Fragments, which are a shorthand syntax for using a specific opaque class from the React package. Spec PR is at facebook/jsx#93.
Fragments are written by completely empty tags (only whitespace is allowed between
<
and>
), and look like<>{'child1'}{'child2'}{'child3'}</>
. This is not written down in the PR's text itself as it is only an AST update, but according to facebook/jsx#93 (comment) it should desugar to<React.Fragment>{'child1'}{'child2'}{'child3'}</React.Fragment>
.The intent is to make returning multiple elements from a component more ergonomic -- instead of returning an array where each child needs to be keyed, return a fragment that preserves the optional key reconciling behavior.
The text was updated successfully, but these errors were encountered: