"use client"

import { useParams } from "next/navigation"
import { useEffect, useState } from "react"

function getHash() {
  return typeof window !== "undefined" ? window.location.hash : undefined
}

function useHash() {
  const [isClient, setIsClient] = useState(false)
  const [hash, setHash] = useState(getHash())
  const params = useParams()

  useEffect(() => {
    setIsClient(true)
    setHash(getHash())
  }, [params, setHash, setIsClient])

  return isClient ? hash : null
}

export default useHash
