show moves history
This commit is contained in:
parent
d782e7f330
commit
e6a8ba41fd
20
src/App.js
20
src/App.js
@ -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>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user