Skip to content

Instantly share code, notes, and snippets.

@pflevy
Created May 17, 2021 19:37
Show Gist options
  • Save pflevy/111a3379246880858e5343ad509536ee to your computer and use it in GitHub Desktop.
Save pflevy/111a3379246880858e5343ad509536ee to your computer and use it in GitHub Desktop.
React.Fragment example where keys are required by React.
const MyComponent = (props) => {
return (
<>
{props.entries.map((entry) => (
<React.Fragment key={entry.id}>
<h2>{entry.header}</h2>
<h3>{entry.subheader}</h3>
</React.Fragment>
))}
</>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment