Components must return a single parent element. Fragments let you group multiple elements without adding an extra DOM node like a wrapper <div>. This keeps markup semantic and CSS layouts clean.
Why Fragments Exist
Before fragments, developers wrapped siblings in unnecessary <div> elements, breaking table semantics, flex/grid layouts, and accessibility structures. Fragments solve this by grouping in the virtual tree only.
Use the short syntax <>...</> for most cases, or <React.Fragment key={id}>...</React.Fragment> when you need a key in a list.
Without fragments, you'd need a wrapper that would break valid <table> structure.
Fragment Syntax Options
// Short syntax (no key allowed)
<>
<Title />
<Content />
</>
// Full syntax (supports key)
import { Fragment } from 'react';
<Fragment key={item.id}>...</Fragment>
Short syntax <>...</> cannot accept props including key.
Use <Fragment key={...}> when mapping groups that need keys.
Fragments do not appear in the DOM or React DevTools tree as nodes.
Prefer fragments over meaningless wrapper divs.
Fragment Quick Reference
When and how to use React Fragments.
Syntax
Supports key?
Use When
<>...</>
No
Group siblings without extra DOM
<Fragment>
Yes
Keyed groups in lists
<div> wrapper
N/A
Need styling/layout container
Array of elements
Each needs key
Returning multiple from map
Fragments vs Wrapper Divs
Use a <div> when you need a hook for CSS (margin, flex child) or a semantic container. Use a fragment when the extra node would interfere with layout or HTML validity.
Situation
Choice
Table row cells
Fragment
Flex column layout
div with flex styles
Modal title + body
Fragment or semantic section
List of keyed groups
Fragment with key
Returning Arrays from Components
You can return an array of elements directly from a component, each with a key. Fragments are usually clearer, but arrays work for flat lists without a wrapper.