From 084c25438672257478e1545b0956467beef3a8e7 Mon Sep 17 00:00:00 2001 From: djmil Date: Mon, 31 Jul 2023 19:10:50 +0200 Subject: [PATCH] clean up --- src/App.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/App.js b/src/App.js index 345dbb8..18b0137 100644 --- a/src/App.js +++ b/src/App.js @@ -58,22 +58,20 @@ function Board({ xIsNext, squares, onPlay }) { } function App() { - const [xIsNext, setXIsNext] = useState(true); const [history, setHistory] = useState([Array(9).fill(null)]); const [currentMove, setCurrentMove] = useState(0); + const xIsNext = currentMove % 2 === 0; const currentSquares = history[currentMove]; function handlePlay(nextSquares) { const nextHistory = [...history.slice(0, currentMove + 1), nextSquares]; setHistory(nextHistory); setCurrentMove(nextHistory.length - 1); - setXIsNext(!xIsNext); } function jumpTo(nextMove) { setCurrentMove(nextMove); setHistory(history.slice(0, nextMove+1)); - setXIsNext(nextMove % 2 === 0); } const moves = history.map((squares, move) => {