Created
February 2, 2022 01:48
-
-
Save jx13xx/ce9997f63ec0e38cf28e8dbf9862cd1e to your computer and use it in GitHub Desktop.
Dyanmic List in React JSX
This file contains 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 comments = [ | |
{id: 1, text: 'Comment One'}, | |
{id: 2, text: 'Comment Two'}, | |
{id: 3, text: 'Comment Three'}, | |
] | |
function App() { | |
return ( | |
<div className='comments'> | |
<h3>Comments ({comments.length})</h3> | |
<ul> | |
{comments.map((comment, index) => ( | |
<li key={index}>{comment.text}</li> | |
))} | |
</ul> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment