The <> </> Shorthand Syntax
What you'll learn: How to use React's empty tag syntax as a cleaner way to group elements without adding extra DOM nodes.
The Cleaner Fragment Syntax
You just learned that React.Fragment lets you group elements without creating an extra wrapper in the DOM. But typing <React.Fragment> and </React.Fragment> every time feels verbose. React gives you a shorthand: empty angle brackets <> and </>.
These work identically to React.Fragment for grouping:
function UserInfo() {
return (
<>
<h1>Welcome</h1>
<p>You are logged in.</p>
</>
);
}
This renders two siblings without a wrapping div or span, just like React.Fragment would—but with less typing.
When to Use Each
Use the shorthand <> in most cases. It's cleaner and more common in modern React code.
Use the full <React.Fragment> syntax only when you need to pass the key prop—the shorthand doesn't support attributes:
// Shorthand doesn't support key
<> won't work here if you need key={item.id}
// Full syntax when needed
<React.Fragment key={item.id}>
{/* ... */}
</React.Fragment>
You haven't learned about key yet, but just know: if you don't need special props, always prefer <>.
Think of It Like Parentheses
Just as parentheses () group expressions in math without changing the result, <> groups JSX without changing the rendered output. They're organizational tools, not visual elements.
Key Takeaway: Use <> </> as your default way to group elements—it's cleaner than React.Fragment and doesn't clutter your JSX. Switch to the full syntax only when you need to add props later.