react map how to render under a specific component or not? 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]));