title: ComponenetMount add fields to array React
body: <p>I am new to react and I am trying to solve a problem, I am getting this data from an API:</p>
  
  <pre><code> rows: [
        { id: 212, title: "Task 1", complete: 20 },
        { id: 5454, title: "Task 2", complete: 40 },
        { id: 39172, title: "Task 3", complete: 60 }
      ]
  </code></pre>
  
  <p>I am using componentDidMount to setState</p>
  
  <pre><code>this.state = { apiData: this.props.getAllData(),
               data: [] }
  componentDidMount(){
     this.state.apiData.then(data =&gt; this.setState({ data: data.rows})) }
  </code></pre>
  
  <p>the data is in the state.data, is working perfectly fine. My question is how I add an index to each row in the rows data from the api, an example like this, the length of the rows is dynamic, could be 10 row or 5 row:</p>
  
  <pre><code> rows: [
        { index: 0, id: 212, title: "Task 1", complete: 20 },
        { index: 1, id: 5454, title: "Task 2", complete: 40 },
        { index: 2, id: 39172, title: "Task 3", complete: 60 }
      ]
  </code></pre>
  
  <p>Can this be done in the componentDidMount()? and setState to the data?</p>