Add key prop to React fragment
Question:
How to add key prop to React fragment? Answer:
<React.Fragment key={id}>
...
</React.Fragment>
Description:
You can create React fragments with the short syntax: <>...</>
However, with this syntax, you can not add key
props. To add a key prop, simply use the normal syntax <React.Fragment key={myKey}>
Reference:
React fragments reference
Share "How to add key prop to React fragment?"
Related snippets:
Tags:
add key to react fragment, react, fragment, key, prop, Technical term:
Add key prop to React fragment