Skip to content

JSX Spec has been updated (Fragment syntax) #19094

Closed
@Jessidhia

Description

@Jessidhia

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.

Metadata

Metadata

Labels

CommittedThe team has roadmapped this issueDomain: JSX/TSXRelates to the JSX parser and emitterSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions