for loop inside render 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: return jsx in for loop

var rows = [];
for (var i = 0; i < numrows; i++) {
    rows.push(ObjectRow());
}
return tbody(rows);

Example 3: 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;
  }