UNPKG

welcome-ui

Version:

Customizable design system with react, typescript, tailwindcss and ariakit.

21 lines (20 loc) 641 B
"use client"; import { useEffect as s, useLayoutEffect as u, useState as a, useRef as f } from "react"; const m = typeof window > "u" ? s : u; function h() { const [n, i] = a({ height: void 0, width: void 0 }), e = f(); return m(() => { const t = new ResizeObserver(([o]) => { const { blockSize: r, inlineSize: c } = o.contentBoxSize[0]; cancelAnimationFrame(e.current), e.current = requestAnimationFrame(() => { i({ height: r, width: c }); }); }); return t.observe(document.documentElement), () => { cancelAnimationFrame(e.current), t.disconnect(); }; }, []), n; } export { h as u };