show moves history

This commit is contained in:
djmil 2023-07-31 18:35:35 +02:00
parent d782e7f330
commit e6a8ba41fd

View File

@ -67,13 +67,31 @@ function App() {
setXIsNext(!xIsNext);
}
function jumpTo(nextMove) {
// TODO
}
const moves = history.map((squares, move) => {
let description;
if (move > 0) {
description = 'Go to move #' + move;
} else {
description = 'Go to game start';
}
return (
<li>
<button onClick={() => jumpTo(move)}>{description}</button>
</li>
);
});
return (
<div className="game">
<div className="game-board">
<Board xIsNext={xIsNext} squares={currentSquares} onPlay={handlePlay} />
</div>
<div className="game-info">
<ol>{/*TODO*/}</ol>
<ol>{moves}</ol>
</div>
</div>
);