UNPKG

@devgateway/dvz-ui-react

Version:

A modular, embeddable React component library for data visualization and UI, built with TypeScript. Provides reusable components for charts, maps, dashboards, and more, with built-in support for internationalization and Redux integration.

26 lines (25 loc) 826 B
import t from "../../utils/deviceType.js"; import { useState as s, useEffect as r } from "react"; const c = (f) => { const { getDeviceType: e, getHeight: i } = {}, [d, o] = s(() => ({ width: typeof window < "u" ? window.innerWidth : 0, ...i && { height: typeof window < "u" ? window.innerHeight : 0 }, ...e && { deviceType: typeof window < "u" ? t() : "desktop" } })); return r(() => { const n = () => { o((w) => ({ ...w, width: window.innerWidth, ...i && { height: window.innerHeight }, ...e && { deviceType: t() } })); }; return typeof window < "u" && (window.addEventListener("resize", n), n()), () => { typeof window < "u" && window.removeEventListener("resize", n); }; }, [i, e]), d; }; export { c as useWindowDimensionsAndDevice };