React Fragments: why and how you should use it

JW
3 min readOct 7, 2020

Fragments are a pretty simple but useful syntax to apply when using JSX.

This quick article will show you the reason behind why Fragments exist and how you can pick between using the old and new syntax for Fragments (Spoiler: you do need to know and use both).

“JSX needs to have one parent element”

A compulsory rule in React is that your JSX needs to have one parent element. There are some good reasons for this, but for brevity we won’t get into it in this article.

--

--

JW

Software Engineer, and avid learner of history.