feat: Add tab navigation to hotel page
This commit is contained in:
22
hooks/useHash.tsx
Normal file
22
hooks/useHash.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
"use client"
|
||||
|
||||
import { useParams } from "next/navigation"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
const getHash = () =>
|
||||
typeof window !== "undefined" ? window.location.hash : undefined
|
||||
|
||||
const useHash = () => {
|
||||
const [isClient, setIsClient] = useState(false)
|
||||
const [hash, setHash] = useState(getHash())
|
||||
const params = useParams()
|
||||
|
||||
useEffect(() => {
|
||||
setIsClient(true)
|
||||
setHash(getHash())
|
||||
}, [params])
|
||||
|
||||
return isClient ? hash : null
|
||||
}
|
||||
|
||||
export default useHash
|
||||
Reference in New Issue
Block a user