File tree Expand file tree Collapse file tree 1 file changed +8
-14
lines changed
workspaces/simon-game/src/app/components Expand file tree Collapse file tree 1 file changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -4,25 +4,19 @@ import playSound from "../util/playSound.ts";
44
55export function App ( ) {
66 let audioContext : AudioContext | null = null ;
7-
8- const handleFreqClick = ( freq : number ) => {
9- if ( ! audioContext ) {
10- audioContext = new window . AudioContext ( ) ;
11- }
12- playSound (
13- audioContext ,
14- freq ,
15- buttonSoundConfig . duration ,
16- buttonSoundConfig . volume ,
17- )
18- }
19-
207 return (
218 < div >
229 { buttonSoundConfig . frequencies . map ( ( freq , index ) => (
2310 < button
2411 key = { index }
25- onClick = { ( ) => handleFreqClick ( freq ) }
12+ onClick = { ( ) =>
13+ playSound (
14+ ( audioContext ??= new AudioContext ( ) ) ,
15+ freq ,
16+ buttonSoundConfig . duration ,
17+ buttonSoundConfig . volume ,
18+ )
19+ }
2620 >
2721 { freq }
2822 </ button >
You can’t perform that action at this time.
0 commit comments