joshwcomeau / use-sound

A React Hook for playing sound effects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot read properties of null (reading 'useRef') when use it in Next.js

MutongXiao opened this issue · comments

when i use it in my next.js project, I got an error:

TypeError: Cannot read properties of null (reading 'useRef')

here is my code
import useSound from 'use-sound'; const [playOn] = useSound('/sounds/switch-on.mp3'); const [playOff] = useSound('/sounds/switch-off.mp3');

i have put the mp3 in '/public/sounds/', but it does not work
how do i fix it, thank you very much

sorry, I made a silly mistake