File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed
workspaces/simon-game/src/app/components Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -5,18 +5,22 @@ import { playNote } from "../util/playNote.ts";
55import { config } from "../constants.ts" ;
66
77export function App ( ) {
8- const [ playerMoves , setPlayerMoves ] = useState < number [ ] > ( [ ] ) ;
8+ const [ playerMoves , setPlayerMoves ] = useState < readonly number [ ] > ( [ ] ) ;
99 return (
10- < div style = { { display : "flex" , gap : 10 } } >
11- { config . boxes . map ( ( box , index ) => (
12- < Box
13- color = { box . color }
14- onClick = { ( ) => {
15- playNote ( box . frequency ) ;
16- setPlayerMoves ( [ ...playerMoves , index ] ) ;
17- } }
18- />
19- ) ) }
20- </ div >
10+ < >
11+ < div style = { { display : "flex" , gap : 10 } } >
12+ { config . boxes . map ( ( box , index ) => (
13+ < Box
14+ key = { index }
15+ color = { box . color }
16+ onClick = { ( ) => {
17+ playNote ( box . frequency ) ;
18+ setPlayerMoves ( ( prev ) => [ ...prev , index ] ) ;
19+ } }
20+ />
21+ ) ) }
22+ </ div >
23+ < pre > { JSON . stringify ( playerMoves , null , 2 ) } </ pre >
24+ </ >
2125 ) ;
2226}
You can’t perform that action at this time.
0 commit comments