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[1]).map(y =>
range(size[0]).map(x => ( range(size[0]).map(x => (
<Cell <Cell
key={x + "-" + "y"}
state={fieldData?.[y]?.[x]?.state ?? CellState.Empty} state={fieldData?.[y]?.[x]?.state ?? CellState.Empty}
content={fieldData?.[y]?.[x]?.content ?? " "} content={fieldData?.[y]?.[x]?.content ?? " "}
/> />
)).concat([<br />]) )).concat([<br key={y + "br"} />])
) )
} }
</div> </div>

View file

@ -9,13 +9,14 @@ export const Keyboard = ({used, onKey}) => {
"ENTER", "Z", "X", "C", "V", "B", "N", "M", "BACK" "ENTER", "Z", "X", "C", "V", "B", "N", "M", "BACK"
]; ];
let newlineCounter = 0;
return <div className="keyboard"> return <div className="keyboard">
{ {
keys.map((key) => { keys.map((key) => {
if (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 { } else {
return <br /> return <br key={"br-" + newlineCounter++} />
} }
}) })
} }