From 5eb93fbba3926dab3454295b14f521b6a9bc11d0 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 5 Jun 2020 11:03:08 -0700 Subject: [PATCH] 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. --- tictactoe/tictactoe.jsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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 [ , ,