Hacker News new | ask | show | jobs
by acemarke 3123 days ago
Several people had already noted [0] that you could implement equivalent behavior by using a component that simply returns its own children:

    const Fragment = ({children}) => children;
    
    // later
    return <Fragment><Component1 /><Component2 /></Fragment>;
Nice to see this added as both a built-in component type and a useful syntax extension. (Now if they'd just modify JSX syntax so that we can pass props by matching local variable names similar to how ES6 object literals work, like `<SomeComponent a b c />`, rather than having that become a defaulted-true boolean, I'd be happy :) )

[0] https://medium.com/@gajus/using-react-v16-to-create-self-des...

2 comments

To be pedantic, it's not 100% equivalent. You can find the nitty-gritty details about the (intentional) differences here: https://github.com/facebook/react/pull/10783.

We did mention the author of react-aux in the blog post though :-)

>Thanks to Gajus Kuizinas and other contributors who prototyped the Fragment component in open source.

That works in ReasonML :)