write for loop inside jsx code example
Example 1: return jsx in for loop
var rows = [];
for (var i = 0; i < numrows; i++) {
rows.push(ObjectRow());
}
return tbody(rows);
Example 2: render text in for loop react in function
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;
}