Skip to content

Commit 4195248

Browse files
committed
feat: added a list to keep track of player moves
1 parent bcd1abe commit 4195248

File tree

1 file changed

+10
-3
lines changed
  • workspaces/simon-game/src/app/components

1 file changed

+10
-3
lines changed

workspaces/simon-game/src/app/components/App.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
import React from "react";
1+
import React, { useState } from "react";
22

33
import { Box } from "./Box.tsx";
44
import { playNote } from "../util/playNote.ts";
55
import { config } from "../constants.ts";
66

77
export function App() {
8+
const [playerMoves, setPlayerMoves] = useState<number[]>([]);
89
return (
910
<div style={{ display: "flex", gap: 10 }}>
10-
{config.boxes.map((box) => (
11-
<Box color={box.color} onClick={() => playNote(box.frequency)} />
11+
{config.boxes.map((box, index) => (
12+
<Box
13+
color={box.color}
14+
onClick={() => {
15+
playNote(box.frequency);
16+
setPlayerMoves([...playerMoves, index]);
17+
}}
18+
/>
1219
))}
1320
</div>
1421
);

0 commit comments

Comments
 (0)