title: How to get DOM element id with OnClick inside map fuction in ReactJs
body: <p>I'm trying to get the DOM element id to change the background of a <code>&lt;td&gt;</code>. I'm printing a calendar with a map function from an array called from an outer function and adding an onclick function to each loop. But when I click the <code>&lt;td&gt;</code> I get the last id from that row. 
  In the alert function, I get the value of the last day from the row</p>
  
  <p>Any suggestions?</p>
  
  <p><a href="https://i.stack.imgur.com/EcyI0.png" rel="nofollow noreferrer">Calendar Example</a>
  This is my code:</p>
  
  <pre><code>cols = new Array(7).fill(0).map((zero, arrayCounter) =&gt; {
    if ((i === 0 &amp;&amp; arrayCounter &lt; weekDay) || numberDays &lt; counterDay + 1) {
      return (
        &lt;td id={arrayCounter} key={arrayCounter}&gt;
          &amp;nbsp;
        &lt;/td&gt;
      );
    } else {
      return (
        counterDay++,
        (
          &lt;td
            id={this.state.month + counterDay}
            key={this.state.month + counterDay}
            onClick={() =&gt; this.handleDays(actualRow, counterDay)}
          &gt;
            {counterDay}
          &lt;/td&gt;
        )
      );
    }
  });
  
  // When press a day
  handleDays = (actualRow, counterDay) =&gt; {
    alert(actualRow + "-" + counterDay);
  };
  </code></pre>