add key value to map funciton react code example
Example 1: map function in react
function NameList() {
const names = ['Bruce', 'Clark', 'Diana']
return (
<div>
{names.map(name => <h2>{name}</h2>)}
</div>
)
}
Example 2: jsx map with index
materials.map((material,index) => console.log(index +" = " + material + " = " + materials[index]));