@dndbuilder.com/react
Version:
Drag and drop builder for React
25 lines (24 loc) • 1.1 kB
JavaScript
import { BuilderConfiguration as o } from "../config/builder.config.js";
import { Breakpoint as e } from "../types/responsive.js";
import { useState as a, useEffect as r } from "react";
const f = () => {
const [c, n] = a(e.DESKTOP);
return r(() => {
if (typeof window > "u") return;
const t = window.frameWindow ?? window, i = t.innerWidth || t.document.documentElement.clientWidth || t.document.body.clientWidth;
i < o.getBreakpoint(e.TABLET).minWidth ? n(e.MOBILE) : i < o.getBreakpoint(e.DESKTOP).minWidth ? n(e.TABLET) : n(e.DESKTOP);
}, []), r(() => {
if (typeof window > "u") return;
const t = window.frameWindow ?? window, i = () => {
const d = t.innerWidth || t.document.documentElement.clientWidth || t.document.body.clientWidth;
d < o.getBreakpoint(e.TABLET).minWidth ? n(e.MOBILE) : d < o.getBreakpoint(e.DESKTOP).minWidth ? n(e.TABLET) : n(e.DESKTOP);
};
return t.addEventListener("resize", i), () => {
t.removeEventListener("resize", i);
};
}, []), c;
};
export {
f as useBreakpoint
};
//# sourceMappingURL=use-breakpoint.js.map