show data using for loop in react code example
Example 1: react for loop in render
render: function() {
const elements = ['one', 'two', 'three'];
return (
<ul>
{elements.map((value, index) => {
return <li key={index}>{value}</li>
})}
</ul>
)
}
Example 2: loop through api response in react
render() {
return (
<div>{this.renderData()}</div>
)
}