Skip to content

Instantly share code, notes, and snippets.

@jx13xx
Created February 2, 2022 01:48
Show Gist options
  • Save jx13xx/ce9997f63ec0e38cf28e8dbf9862cd1e to your computer and use it in GitHub Desktop.
Save jx13xx/ce9997f63ec0e38cf28e8dbf9862cd1e to your computer and use it in GitHub Desktop.
Dyanmic List in React JSX
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