@arolariu/components
Version:
🎨 70+ beautiful, accessible React components built on Radix UI. TypeScript-first, tree-shakeable, SSR-ready. Perfect for modern web apps, design systems & rapid prototyping. Zero config, maximum flexibility! ⚡
28 lines (27 loc) • 936 B
JavaScript
"use client";
import { useEffect, useState } from "react";
const MOBILE_BREAKPOINT = 768;
function useWindowSize() {
const [windowSize, setWindowSize] = useState({
width: null,
height: null
});
useEffect(()=>{
function __handleResize__() {
setWindowSize({
width: globalThis.window.innerWidth,
height: globalThis.window.innerHeight
});
}
globalThis.window.addEventListener("resize", __handleResize__);
__handleResize__();
return ()=>globalThis.window.removeEventListener("resize", __handleResize__);
}, []);
return {
windowSize,
isMobile: "number" == typeof windowSize.width && windowSize.width < MOBILE_BREAKPOINT,
isDesktop: "number" == typeof windowSize.width && windowSize.width >= MOBILE_BREAKPOINT
};
}
export { useWindowSize };
//# sourceMappingURL=useWindowSize.js.map