joshwcomeau / use-sound

A React Hook for playing sound effects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sound is not playing on Next.js. No bugs, but just sound doesn't play. Please help!

iamalaziz opened this issue · comments

import useSound from 'use-sound'
import switchOn from '../assets/switch-on.mp3'

const [playSwitchOn] = useSound(switchOn)

const switchTheme = () => {
setTheme(theme === 'dark' || resolvedTheme === 'dark' ? 'light' : 'dark')
playSwitchOn()
}

<button
    aria-label="Toggle Dark Mode"
    type="button"
    className="flex h-8 w-8 items-center justify-center p-2"
    onClick={switchTheme}
  >