Fragments: Keyed Fragments
Keyed Fragments
A use case for keyed fragments is mapping a collection to an array of fragments.
function Glossary(props) {
return (
<dl>
{props.items.map(item => (
// Without the `key`, React will fire a key warning
<React.Fragment key={item.id}>
<dt>{item.term}</dt>
<dd>{item.description}</dd>
</React.Fragment>
))}
</dl>
);
} Fragments declared with the explicit <React.Fragment> syntax may have keys.
Semantic portal