how to iterate array in a functional component of react code example
Example 1: react js iterate object
<div className="iterate-object">
{
<ul>
{Object.keys(OBJECTHERE).map(function(keyName, keyIndex) {
return (
<li key={keyName}>
{keyName}
{console.log(OBJECTHERE[keyName])}
</li>
)
})}
</ul>
}
</div>
Example 2: react loop through array
this.items = this.state.cart.map((item, key) => <li key={item.id}>{item.name}</li>);