How to Fix React Fragment Key Prop Missing
DodaTech
Updated 2026-06-26
1 min read
The Problem
In this quick-fix, you'll learn how to add key props to React Fragments in list rendering. This matters because React requires key props for array elements shorthand syntax doesnt support keys. In real-world applications, this pattern appears in rendering lists of description lists table rows in map iterations.
The Wrong Way
function ItemList({ items }) {
return items.map(item => <>
<dt>{item.term}</dt>
<dd>{item.desc}</dd>
</>);
}
Warning: Each child in a list should have a unique key prop
The Right Way
function ItemList({ items }) {
return items.map(item => (
<React.Fragment key={item.id}>
<dt>{item.term}</dt>
<dd>{item.desc}</dd>
</React.Fragment>
));
}
No warning -- key properly assigned to Fragment
Prevention
- Use <React.Fragment key={...}> not <> in lists
- Provide stable unique keys for mapped elements
- Keys only need uniqueness among siblings
FAQ
This guide is brought to you by DodaTech — built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.
← Previous
How to Fix React Error Boundary Not Catching Errors
Next →
How to Fix React Higher-Order Component Issues
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro