can someone explain to me please why this code works
renderSquare(i) {
return (
<Square
value={this.state.squares[i]}
onClick={() => this.handleClick(i)}
/>
);
}
but if remove the arrow function in the elements onClick value
renderSquare(i) {
return (
<Square
value={this.state.squares[i]}
onClick={this.handleClick(i)}
/>
);
}
it gives me the error Warning: Cannot update during an existing state transition (such as within render). Render methods should be a pure function of props and state.%s
The full code can be found here https://codepen.io/gaearon/pen/KmmrBy?editors=0010