Answers for "how to map array of objects in react"

20

map function in react

function NameList() {
	const names = ['Bruce', 'Clark', 'Diana']
    return (
    	<div>
      {names.map(name => <h2>{name}</h2>)}
      	</div>
    )
}
Posted by: Guest on October-15-2020
4

how to map array of objects in react

[{
    name: 'Sam',
    email: '[email protected]'
 },
 {
    name: 'Ash',
    email: '[email protected]'
 }
].map( ( {name, email} ) => {
    return <p key={email}>{name} - {email}</p>
})
Posted by: Guest on May-30-2021

Code answers related to "how to map array of objects in react"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language