In this part, I will show you about good benefits when using fragments in React.
Previous articles:
Fragments to group a list of children without adding extra nodes to the DOM, and has no effect on the resulting DOM. It is the same as if the elements were not grouped.
You need to use either or a shorter syntax having an empty tag (<></>).
Below is an example of how to use fragments inside the UsernameWithAvatar component.
const UsernameWithAvatar({username, description, photoUrl}) { return ( <> <h2>{username}</h2> <p>{description}</p> <img src={photoUrl} alt="Username with avatar"/> </> ); }
Wish you all good study !!!