Fixed duplicate list child key warning

This commit is contained in:
Arnaud Vergnet 2020-07-21 22:35:38 +02:00
parent ae3d9310d6
commit ccf196abaa
4 changed files with 56 additions and 64 deletions

View file

@ -26,7 +26,6 @@ class CellComponent extends React.PureComponent<Props> {
borderWidth: 1, borderWidth: 1,
aspectRatio: 1, aspectRatio: 1,
}} }}
key={item.key}
/> />
); );
} }

View file

@ -31,7 +31,7 @@ class GridComponent extends React.Component<Props> {
} }
getCellRender = (item: Cell) => { getCellRender = (item: Cell) => {
return <CellComponent cell={item}/>; return <CellComponent cell={item} key={item.key}/>;
}; };
getGrid() { getGrid() {

View file

@ -109,6 +109,7 @@ export default class GameLogic {
onClock(callback: Function) { onClock(callback: Function) {
this.#gameTime++; this.#gameTime++;
console.log(this.#gameTime);
callback(this.#gameTime); callback(this.#gameTime);
} }

View file

@ -110,7 +110,7 @@ class GameStartScreen extends React.Component<Props, State> {
animation={"fadeInDownBig"} animation={"fadeInDownBig"}
delay={animDelay} delay={animDelay}
duration={animDuration} duration={animDuration}
key={index.toString()} key={"piece" + index.toString()}
style={{ style={{
width: size + "%", width: size + "%",
position: "absolute", position: "absolute",
@ -118,21 +118,14 @@ class GameStartScreen extends React.Component<Props, State> {
left: left + "%", left: left + "%",
}} }}
> >
<View style={{
transform: [{rotateZ: rot + "deg"}],
}}>
<GridComponent <GridComponent
width={4} width={4}
height={4} height={4}
grid={item} grid={item}
style={{ style={{
marginRight: 5, transform: [{rotateZ: rot + "deg"}],
marginLeft: 5,
marginBottom: 5,
}} }}
/> />
</View>
</Animatable.View> </Animatable.View>
); );
})} })}
@ -379,7 +372,6 @@ class GameStartScreen extends React.Component<Props, State> {
getMainContent() { getMainContent() {
return ( return (
<View style={{flex: 1}}> <View style={{flex: 1}}>
{ {
this.gameStats != null this.gameStats != null