UNPKG

stone-kit

Version:
15 lines (14 loc) 590 B
import { useState as u, useCallback as c, useEffect as i } from "react"; const a = () => { const [e, n] = u(0), t = c(() => { n(window.innerWidth); }, [n]); i(() => (window.addEventListener("resize", t), () => window.removeEventListener("resize", t)), []), i(() => { t(); }, []); const s = e < 1024, o = typeof window < "u" ? window.innerWidth < 768 : !1, r = e >= 768 && e < 1440, d = e > 1023 && e < 1440, l = e >= 1440; return { currentClientWidth: e, isMobile: s, isTablet: d, isDesktop: l, isMobileBorder: o, isFullTablet: r }; }; export { a as useClientWidth };