Skip to content

Commit 8f0247d

Browse files
committed
chore: applying feedback
1 parent fedeb64 commit 8f0247d

File tree

1 file changed

+8
-14
lines changed
  • workspaces/simon-game/src/app/components

1 file changed

+8
-14
lines changed

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,19 @@ import playSound from "../util/playSound.ts";
44

55
export 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>

0 commit comments

Comments
 (0)