Skip to content

Commit 5b8a5f0

Browse files
committed
extract to a function
1 parent db6be39 commit 5b8a5f0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apps/hyparquet-demo/src/Welcome.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,17 @@ import hyparquetMp3 from './assets/hyparquet.mp3'
66
export default function Welcome(): ReactNode {
77
const audio = useRef<HTMLAudioElement>(null)
88

9+
function playAudio() {
10+
audio.current?.play().catch(() => {
11+
console.warn('Failed to play audio')
12+
})
13+
}
14+
915
return <div id="welcome">
1016
<h1>hyparquet</h1>
1117
<sub>img
1218
/haɪ pɑːrˈkeɪ/
13-
<img src={audioSvg} alt="play hyparquet pronunciation" height="18" width="18" onClick={() => {audio.current?.play().catch(() => { return undefined})}} />
19+
<img src={audioSvg} alt="play hyparquet pronunciation" height="18" width="18" onClick={playAudio} />
1420
</sub>
1521
<audio ref={audio} id="audio" src={hyparquetMp3}></audio>
1622
<h2>in-browser parquet file reader</h2>

0 commit comments

Comments
 (0)