React Fragments in 2 Minutes
May 7, 2018
Sometimes there are topics I hear about and want to dig into, but don’t have time to right away.
Then my mind starts to play tricks on me and it somehow becomes more and more difficult to return to them later. I just keep putting it off. It festers, and it takes waaayyyyy longer than it should before I finally set aside time for it. Then I realize it was pretty darn simple and I should have just knocked it out right away.
React’s new Fragments feature is one of those things.
Fragments are a handy way to return multiple elements from a component without having to wrap them in a container:
Note: the
<></>
<React.Fragment></React.Fragment>
<React.Fragment>
That’s it!
Want more like this? Sign up to get one article delivered weekly by email.