18 lines
605 B
TypeScript
18 lines
605 B
TypeScript
'use client'
|
|
import { useEffect, useState } from 'react'
|
|
|
|
/**
|
|
* Returns true only after the component has mounted on the client. Used to gate
|
|
* consent UI (CookieBanner, CookieButton) so it renders nothing during SSR /
|
|
* first paint — preventing the React 19 / Next hydration mismatch that projects
|
|
* were working around with their own setTimeout-based ConsentWrapper. Built into
|
|
* the components now, so no project wrapper is needed.
|
|
*/
|
|
export function useIsMounted(): boolean {
|
|
const [mounted, setMounted] = useState(false)
|
|
useEffect(() => {
|
|
setMounted(true)
|
|
}, [])
|
|
return mounted
|
|
}
|