terrible/app/hooks/use-is-hydrated.js
2024-03-12 11:20:28 -05:00

8 lines
277 B
JavaScript

import {useState, useEffect, useLayoutEffect} from "react";
export default function useIsHydrated() {
const [isHydrated, setIsHydrated] = useState(false);
('undefined' === typeof window ? useEffect : useLayoutEffect)(() => setIsHydrated(true), []);
return isHydrated;
}