ultisuite-client/lib/stores/hydration.ts
2026-05-15 17:40:17 +02:00

17 lines
442 B
TypeScript

"use client"
import { useEffect, useState } from "react"
/**
* Returns true once Zustand stores have rehydrated from localStorage.
* Use to guard rendering that depends on persisted state so SSR doesn't
* flash stale defaults before the real persisted data arrives.
*/
export function useStoreHydrated(): boolean {
const [hydrated, setHydrated] = useState(false)
useEffect(() => {
setHydrated(true)
}, [])
return hydrated
}