Skip to content
doubtly

2 answers

The empty tags <> </> are the short syntax for a React Fragment. They let a component return several elements without adding an extra node to the DOM.

A component must return a single parent element. Instead of wrapping everything in an unnecessary <div>, use a fragment:

function Info() {
  return (
    <>
      <h2>Title</h2>
      <p>Some text</p>
    </>
  );
}

Only the h2 and p appear in the final HTML. This keeps the DOM clean and avoids breaking layouts such as table rows or flex/grid children. The short form cannot take attributes; if you need a key (e.g. in a list), write <React.Fragment key={id}> instead.

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.