Created
January 26, 2021 07:33
-
-
Save quantumchuckles/cc4a4a6ea265c1715661dea05109f337 to your computer and use it in GitHub Desktop.
For-loop in JSX with id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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