[React.js] Component Iteration
The key must be unique, it could be an index or unique value from the list item.
import React from "react";
function IterationSample() {
const names = ["snow", "ice", "fire", "wind"];
const nameList = names.map((name, index) => <li key={index}>{name}</li>);
return (
<div>
<ul>{nameList}</ul>
</div>
);
}
export default IterationSample;
Comments