MCPcopy Index your code
hub / github.com/ColmapView/Colmapview.github.io / useIsMobile

Function useIsMobile

src/hooks/useIsMobile.ts:9–23  ·  view source on GitHub ↗
(breakpoint: number = BREAKPOINTS.mobile)

Source from the content-addressed store, hash-verified

7 * @returns true if viewport width is below the breakpoint
8 */
9export function useIsMobile(breakpoint: number = BREAKPOINTS.mobile): boolean {
10 const [isMobile, setIsMobile] = useState(
11 () => typeof window !== 'undefined' && window.innerWidth < breakpoint
12 );
13
14 useEffect(() => {
15 function checkMobile(): void {
16 setIsMobile(window.innerWidth < breakpoint);
17 }
18 window.addEventListener('resize', checkMobile);
19 return () => window.removeEventListener('resize', checkMobile);
20 }, [breakpoint]);
21
22 return isMobile;
23}

Callers 1

DropZoneFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected