Skip to content

Commit

Permalink
3rd step: Add handleClick functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrcel97 committed Aug 22, 2018
1 parent f1c64d3 commit 2cde775
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ class Board extends React.Component {
};
}

renderSquare(i) {
handleClick(i) {
const squares = this.state.squares.slice(); // Shallow copy
squares[i] = 'X'; // (*)... Then this number will be used to update only the specific Square.
this.setState({squares: squares});
}

renderSquare(i) { // When we create a Square we assign a numer to it ...(*)
return (
<Square
value={this.state.squares[i]} // Set the 'this.props.value' of the Square Component to 'X', 'O' or Null.
Expand Down

0 comments on commit 2cde775

Please sign in to comment.