From: Carl Worth <cworth@cworth.org> Date: Fri, 5 Jun 2020 18:03:08 +0000 (-0700) Subject: Avoid some repeated references to "this.type" X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=5eb93fbba3926dab3454295b14f521b6a9bc11d0;p=lmno.games Avoid some repeated references to "this.type" Simpler to just cache this is "state" at the beginning of the function and then use that throughout. --- diff --git a/tictactoe/tictactoe.jsx b/tictactoe/tictactoe.jsx index f5951f1..326a5dd 100644 --- a/tictactoe/tictactoe.jsx +++ b/tictactoe/tictactoe.jsx @@ -253,28 +253,29 @@ class Game extends React.Component { } render() { - const history = this.state.history; - const current = history[this.state.step_number]; + const state = this.state; + const history = state.history; + const current = history[state.step_number]; const winner = calculate_winner(current.squares); let status; if (winner) { status = "Winner: " + winner; } else { - status = "Next player: " + (Team.properties[this.state.next_to_play].name); + status = "Next player: " + (Team.properties[state.next_to_play].name); } return [ <GameInfo key="game-info" - id={this.state.game_info.id} - url={this.state.game_info.url} + id={state.game_info.id} + url={state.game_info.url} />, <PlayerInfo key="player-info" - id={this.state.player_info.id} - name={this.state.player_info.name} - team={this.state.player_info.team} + id={state.player_info.id} + name={state.player_info.name} + team={state.player_info.team} />, <div key="game" className="game"> <button className="inline"