From 0602929f86c1939b1a52188ecf91096d087f98c7 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 4 Jun 2020 16:19:11 -0700 Subject: [PATCH] Rename stepNumber to step_number And drop the dead-code jumpTo while we're at it. I'm gradually rewriting the original tutorial code into my own style. --- tictactoe/tictactoe.jsx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tictactoe/tictactoe.jsx b/tictactoe/tictactoe.jsx index 42c32ef..d462ae1 100644 --- a/tictactoe/tictactoe.jsx +++ b/tictactoe/tictactoe.jsx @@ -118,7 +118,7 @@ class Game extends React.Component { squares: Array(9).fill(null) } ], - stepNumber: 0, + step_number: 0, next_to_play: Team.X }; } @@ -134,13 +134,13 @@ class Game extends React.Component { squares: Array(9).fill(null) } ], - stepNumber: 0, + step_number: 0, next_to_play: Team.X }); } receiveMove(i) { - const history = this.state.history.slice(0, this.state.stepNumber + 1); + const history = this.state.history.slice(0, this.state.step_number + 1); const current = history[history.length - 1]; const squares = current.squares.slice(); if (calculateWinner(squares) || squares[i]) { @@ -158,7 +158,7 @@ class Game extends React.Component { squares: squares } ]), - stepNumber: history.length, + step_number: history.length, next_to_play: next_to_play }); } @@ -174,16 +174,9 @@ class Game extends React.Component { } } - jumpTo(step) { - this.setState({ - stepNumber: step, - next_to_play: (step % 2) === 0 - }); - } - render() { const history = this.state.history; - const current = history[this.state.stepNumber]; + const current = history[this.state.step_number]; const winner = calculateWinner(current.squares); let status; -- 2.43.0