for loop inside react render 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: react for loop

<tbody>
  {[...Array(10)].map((x, i) =>
    <ObjectRow key={i} />
  )}
</tbody>

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;
  }