Skip to content

JSX Spec has been updated (Fragment syntax) #19094

Description

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 react/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 react/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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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