MCPcopy Create free account
hub / github.com/codeaashu/claude-code / useMediaQuery

Function useMediaQuery

web/hooks/useMediaQuery.ts:5–17  ·  view source on GitHub ↗
(query: string)

Source from the content-addressed store, hash-verified

3import { useState, useEffect } from "react";
4
5export function useMediaQuery(query: string): boolean {
6 const [matches, setMatches] = useState(false);
7
8 useEffect(() => {
9 const mq = window.matchMedia(query);
10 setMatches(mq.matches);
11 const handler = (e: MediaQueryListEvent) => setMatches(e.matches);
12 mq.addEventListener("change", handler);
13 return () => mq.removeEventListener("change", handler);
14 }, [query]);
15
16 return matches;
17}
18
19/** < 768px */
20export function useIsMobile(): boolean {

Callers 3

useIsMobileFunction · 0.85
useIsTabletFunction · 0.85
useIsDesktopFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected