Skip to content

Wrap preact.Fragment with preact.createElement#35418

Merged
caroqliu merged 2 commits intoampproject:mainfrom
caroqliu:react-fragment
Jul 29, 2021
Merged

Wrap preact.Fragment with preact.createElement#35418
caroqliu merged 2 commits intoampproject:mainfrom
caroqliu:react-fragment

Conversation

@caroqliu
Copy link
Copy Markdown
Contributor

@caroqliu caroqliu commented Jul 27, 2021

While preact.Fragment is a function, react.Fragment is not. This PR nests with preact.createElement to account for remapping preact -> react. Fixes #35412. Related to #35678

@caroqliu caroqliu requested a review from jridgewell July 27, 2021 18:29
@developit
Copy link
Copy Markdown

Might also be worth considering having this return props.children to avoid the nesting altogether. Using <Fragment key="" /> will still work like it would on a Fragment, because it'll be applied to the component:

function Fragment(props) {
  return props.children;
}

@caroqliu
Copy link
Copy Markdown
Contributor Author

Might also be worth considering having this return props.children to avoid the nesting altogether. Using <Fragment key="" /> will still work like it would on a Fragment, because it'll be applied to the component:

function Fragment(props) {
  return props.children;
}

Thanks for the recommendation, updated.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bento: TypeError when using React.Fragment

5 participants