Add key properties to GameInfo and PlayerInfo blocks
authorCarl Worth <cworth@cworth.org>
Fri, 5 Jun 2020 17:15:59 +0000 (10:15 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 6 Jun 2020 11:45:08 +0000 (04:45 -0700)
This silences the warning that React gives:

    Warning: Each child in a list should have a unique "key" prop

Which I seem to get every time I add a new list of elements.

tictactoe/tictactoe.jsx

index 498e708fbf9cc3d733517ff91215300952afee31..5bb84f1b44790f9e08f22af22fef321c421b958c 100644 (file)
@@ -247,15 +247,17 @@ class Game extends React.Component {
 
     return [
       <GameInfo
+        key="game-info"
         id={this.state.game_info.id}
         url={this.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}
       />,
-      <div className="game">
+      <div key="game" className="game">
         <div>{status}</div>
         <div className="game-board">
           <Board