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) 831 B
import t from "../../utils/deviceType.js"; import { useState as r, useEffect as f } from "react"; const c = (d) => { const { getDeviceType: e, getHeight: i } = d || {}, [o, w] = r(() => ({ width: typeof window < "u" ? window.innerWidth : 0, ...i && { height: typeof window < "u" ? window.innerHeight : 0 }, ...e && { deviceType: typeof window < "u" ? t() : "desktop" } })); return f(() => { const n = () => { w((s) => ({ ...s, 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]), o; }; export { c as useWindowDimensionsAndDevice };