diff --git a/src/index.js b/src/index.js index ca2029d..6f0fe35 100644 --- a/src/index.js +++ b/src/index.js @@ -22,7 +22,12 @@ function Square(props){ handleClick(i) { const squares = this.state.squares.slice(); squares[i] = this.state.xIsNext ? 'X' : 'O'; - this.setState({squares: squares,xIsNext: !this.state.xIsNext}); + this.setState( + { + squares: squares, + xIsNext: !this.state.xIsNext + } + ); } renderSquare(i) { @@ -39,7 +44,13 @@ function Square(props){ } render() { - const status = 'Next player: ' + (this.state.xIsNext ? 'X' : 'O'); + const winner = calculateWinner(this.state.squares); + let status; + if (winner) { + status = 'Winner: ' + winner; + } else { + status = 'Next Player: ' + (this.state.xIsNext ? 'X' : 'O') + } return (