const n = 8;
{[...Array(n)].map((elementInArray, index) => (
<div className="" key={index}> Whatever needs to be rendered repeatedly... </div>
)
)}
render: function() {
const elements = ['one', 'two', 'three'];
return (
<ul>
{elements.map((value, index) => {
return <li key={index}>{value}</li>
})}
</ul>
)
}
myLoopFunction() {
var myArray = [];
var i;
for (i = 0; i < this.state.events.length; i++) {
myArray[i] = (
<Event
time={this.state.events[i].time}
title={this.state.events[i].title}
/>
);
}
return myArray;
}
const n = 8;
{[...Array(n)].map((elementInArray, index) => (
<div className="" key={index}> Whatever needs to be rendered repeatedly... </div>
)
)}
for loop react