joshwcomeau / use-sound

A React Hook for playing sound effects
MIT License
2.75k stars 98 forks source link

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

Closed iamalaziz closed 1 year ago

iamalaziz commented 1 year ago

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}
  >