Skip to content

Commit 2cde775

Browse files
committed
3rd step: Add handleClick functionality.
1 parent f1c64d3 commit 2cde775

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ class Board extends React.Component {
2525
};
2626
}
2727

28-
renderSquare(i) {
28+
handleClick(i) {
29+
const squares = this.state.squares.slice(); // Shallow copy
30+
squares[i] = 'X'; // (*)... Then this number will be used to update only the specific Square.
31+
this.setState({squares: squares});
32+
}
33+
34+
renderSquare(i) { // When we create a Square we assign a numer to it ...(*)
2935
return (
3036
<Square
3137
value={this.state.squares[i]} // Set the 'this.props.value' of the Square Component to 'X', 'O' or Null.

0 commit comments

Comments
 (0)