mlmorg / react-hyperscript

Hyperscript syntax for React.js markup
MIT License
710 stars 45 forks source link

Support Fragments #36

Closed lo1tuma closed 6 years ago

lo1tuma commented 6 years ago

Improved fragment support has been shipped with React 16.2.0. As there is even a special JSX syntax for fragments I thought it would be nice to also have a convenient way in react-hyperscript to create fragments.


My API proposal would be the following:

h(listOfElements)

Returns a React element.

Example:

h([
    h('li', 'first'),
    h('li', 'second'),
    h('li', 'third')
]);

This would be equivalent to:

h(React.Fragment, [
    h('li', 'first'),
    h('li', 'second'),
    h('li', 'third')
]);

I would be happy to implement this if the proposal gets accepted.

lo1tuma commented 6 years ago

ping @mlmorg

lo1tuma commented 6 years ago

@mlmorg Do you have any feedback?

mlmorg commented 6 years ago

Sorry for the delay (holiday time)! This sounds good to me. If you're able to implement this, I would happily merge!

lo1tuma commented 6 years ago

Thanks for the feedback @mlmorg I’ve filed a PR to implement this proposal, see #39.