From ccf196abaafc170f19ff2919c4de10db5d4d3d3b Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Tue, 21 Jul 2020 22:35:38 +0200 Subject: [PATCH] Fixed duplicate list child key warning --- src/screens/Game/components/CellComponent.js | 1 - src/screens/Game/components/GridComponent.js | 2 +- src/screens/Game/logic/GameLogic.js | 1 + src/screens/Game/screens/GameStartScreen.js | 116 +++++++++---------- 4 files changed, 56 insertions(+), 64 deletions(-) diff --git a/src/screens/Game/components/CellComponent.js b/src/screens/Game/components/CellComponent.js index 27a9557..015d0b1 100644 --- a/src/screens/Game/components/CellComponent.js +++ b/src/screens/Game/components/CellComponent.js @@ -26,7 +26,6 @@ class CellComponent extends React.PureComponent { borderWidth: 1, aspectRatio: 1, }} - key={item.key} /> ); } diff --git a/src/screens/Game/components/GridComponent.js b/src/screens/Game/components/GridComponent.js index 497f9e4..9d3a271 100644 --- a/src/screens/Game/components/GridComponent.js +++ b/src/screens/Game/components/GridComponent.js @@ -31,7 +31,7 @@ class GridComponent extends React.Component { } getCellRender = (item: Cell) => { - return ; + return ; }; getGrid() { diff --git a/src/screens/Game/logic/GameLogic.js b/src/screens/Game/logic/GameLogic.js index bf5c9e8..d562e6f 100644 --- a/src/screens/Game/logic/GameLogic.js +++ b/src/screens/Game/logic/GameLogic.js @@ -109,6 +109,7 @@ export default class GameLogic { onClock(callback: Function) { this.#gameTime++; + console.log(this.#gameTime); callback(this.#gameTime); } diff --git a/src/screens/Game/screens/GameStartScreen.js b/src/screens/Game/screens/GameStartScreen.js index 37033f4..56ae256 100644 --- a/src/screens/Game/screens/GameStartScreen.js +++ b/src/screens/Game/screens/GameStartScreen.js @@ -110,7 +110,7 @@ class GameStartScreen extends React.Component { animation={"fadeInDownBig"} delay={animDelay} duration={animDuration} - key={index.toString()} + key={"piece" + index.toString()} style={{ width: size + "%", position: "absolute", @@ -118,21 +118,14 @@ class GameStartScreen extends React.Component { left: left + "%", }} > - - - - + ); })} @@ -379,34 +372,33 @@ class GameStartScreen extends React.Component { getMainContent() { return ( - - - { - this.gameStats != null - ? this.getPostGameContent(this.gameStats) - : this.getWelcomeText() - } - - {this.getTopScoresRender()} - + + { + this.gameStats != null + ? this.getPostGameContent(this.gameStats) + : this.getWelcomeText() + } + + {this.getTopScoresRender()} + ) } @@ -425,24 +417,24 @@ class GameStartScreen extends React.Component { start={{x: 0, y: 0}} end={{x: 0, y: 1}} > - - {this.getMainContent()} - - + + {this.getMainContent()} + +