Skip to content

Instantly share code, notes, and snippets.

@ComradeCat24
Created January 26, 2021 07:33
Show Gist options
  • Save ComradeCat24/cc4a4a6ea265c1715661dea05109f337 to your computer and use it in GitHub Desktop.
Save ComradeCat24/cc4a4a6ea265c1715661dea05109f337 to your computer and use it in GitHub Desktop.
For-loop in JSX with id
const Loop = () => {
const animals = [
{ id: 1, animal: "Dog" },
{ id: 2, animal: "Bird" },
{ id: 3, animal: "Cat" },
{ id: 4, animal: "Mouse" },
{ id: 5, animal: "Horse" },
];
return (
<ul>
{animals.map((item) => (
<h5 key={item.id}>{item.animal}</h5>
))}
</ul>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment