@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! ⚡
19 lines (18 loc) • 690 B
JavaScript
"use client";
import { useEffect, useState } from "react";
const MOBILE_BREAKPOINT = 768;
function useIsMobile() {
const [isMobile, setIsMobile] = useState(null);
useEffect(()=>{
const mql = globalThis.window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const onChange = ()=>{
setIsMobile(globalThis.window.innerWidth < MOBILE_BREAKPOINT);
};
mql.addEventListener("change", onChange);
setIsMobile(globalThis.window.innerWidth < MOBILE_BREAKPOINT);
return ()=>mql.removeEventListener("change", onChange);
}, []);
return Boolean(isMobile);
}
export { useIsMobile };
//# sourceMappingURL=useIsMobile.js.map