fix: missing keys in react array

This commit is contained in:
sigmasternchen 2024-09-20 20:12:57 +02:00
parent 121866e86a
commit 7d049af52d
2 changed files with 5 additions and 3 deletions

View file

@ -10,10 +10,11 @@ export const Field = ({size, fieldData}) => {
range(size[1]).map(y =>
range(size[0]).map(x => (
<Cell
key={x + "-" + "y"}
state={fieldData?.[y]?.[x]?.state ?? CellState.Empty}
content={fieldData?.[y]?.[x]?.content ?? " "}
/>
)).concat([<br />])
)).concat([<br key={y + "br"} />])
)
}
</div>

View file

@ -9,13 +9,14 @@ export const Keyboard = ({used, onKey}) => {
"ENTER", "Z", "X", "C", "V", "B", "N", "M", "BACK"
];
let newlineCounter = 0;
return <div className="keyboard">
{
keys.map((key) => {
if (key) {
return <Key onKey={onKey} state={used[key] ?? CellState.Unknown} content={key} />;
return <Key key={key} onKey={onKey} state={used[key] ?? CellState.Unknown} content={key} />;
} else {
return <br />
return <br key={"br-" + newlineCounter++} />
}
})
}