Photo by Matthew T Rader on Unsplash

Have you ever noticed that in react components every element must wrap inside a parent or else give an error as follows.

And pop up following error.

The reason is you have to wrap those inside a parent or else it will not compile from JSX. To avoid that React Fragments have been introduced. React Fragments can be used as follows.

In React there is a newer way of Fragmenting which is using just <> and </> which can be implemented as follows.

References

Hopefully this is helpful.

If you have found this helpful please hit that 👏 and share it on social media :).

Technical Writer | Tech Enthusiast | Open source contributor