UNPKG

@droppii-org/chat-sdk

Version:

Droppii React Chat SDK

16 lines (15 loc) 565 B
"use client"; import { useEffect, useState } from "react"; export const useIsMobile = (breakpoint = 768) => { const [isMobile, setIsMobile] = useState(() => { if (typeof window === "undefined") return false; return window.innerWidth < breakpoint; }); useEffect(() => { const handleResize = () => setIsMobile(window.innerWidth < breakpoint); window.addEventListener("resize", handleResize); return () => window.removeEventListener("resize", handleResize); }, [breakpoint]); return isMobile; };