Fragment Purpose
Question
Why use React Fragments?
Hint
Fragments avoid unnecessary wrapper divs in the DOM.
Explanation
React Fragments let you group multiple elements without adding an extra DOM node. This matters for CSS (flexbox/grid layouts break with extra wrappers), HTML validity (tables cannot have div children), and performance (fewer DOM nodes). Use <Fragment> with a key prop, or the shorthand <>...</> (which cannot take a key). Fragments are essential when mapping lists that return multiple elements per item.
Related Resources
Related Lessons
- Fragments
Learn fragments.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.