Transform an array of items v1
const PostList() { const posts = [ { title: 'Montreal', id: 1 }, { title: 'Lviv', id: 2 } ]; const postList = posts.map((post) => <li key={post.id}> {post.title} </li> ); return ( <ul>{postList}</ul> ); } export default PostList;
Transform an array of items v2
const PostList() { const posts = [ { title: 'Montreal', id: 1 }, { title: 'Lviv', id: 2 } ]; return ( <ul> {posts.map((post) => ( <li key={post.id}> {post.title} </li> ))} </ul> ); } export default PostList;