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,
aspectRatio: 1,
}}
key={item.key}
/>
);
}

View file

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

View file

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

View file

@ -110,7 +110,7 @@ class GameStartScreen extends React.Component<Props, State> {
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<Props, State> {
left: left + "%",
}}
>
<View style={{
transform: [{rotateZ: rot + "deg"}],
}}>
<GridComponent
width={4}
height={4}
grid={item}
style={{
marginRight: 5,
marginLeft: 5,
marginBottom: 5,
transform: [{rotateZ: rot + "deg"}],
}}
/>
</View>
</Animatable.View>
);
})}
@ -379,7 +372,6 @@ class GameStartScreen extends React.Component<Props, State> {
getMainContent() {
return (
<View style={{flex: 1}}>
{
this.gameStats != null