map array values and render react code example
Example 1: 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>
})
Example 2: how map work in react
{this.state.data.map((person) => <TableRow key = {shortid.generate()} data = {person} />)}