text: import { useState, useEffect } from 'react'
  
  const useAudio = (url) => {
      const [audio] = useState(new Audio(url))
      const [play, setPlay] = useState(false)
  
      const handlePlaySound = () => setPlay(!play)
  
      useEffect(() => {
          audio.muted = false
          play ? audio.play() : audio.pause()
      }, [play])
  
      useEffect(() => {
          audio.addEventListener('ended', () => setPlaying(false))
          return () => {
              audio.removeEventListener('ended', () => setPlaying(false))
          }
      }, [])
  
      return [play, handlePlaySound]
  }
  
  export default useAudio
  