MCPcopy
hub / github.com/intentui/intentui / useIsMobile

Function useIsMobile

src/hooks/use-mobile.ts:4–18  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2
3const MOBILE_BREAKPOINT = 768
4export function useIsMobile() {
5 const [isMobile, setIsMobile] = useState<boolean | undefined>(undefined)
6
7 useEffect(() => {
8 const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
9 const onChange = () => {
10 setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
11 }
12 mql.addEventListener('change', onChange)
13 setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
14 return () => mql.removeEventListener('change', onChange)
15 }, [])
16
17 return !!isMobile
18}

Callers 15

DatePickerOverlayFunction · 0.90
ChartFunction · 0.90
NavbarProviderFunction · 0.90
SidebarProviderFunction · 0.90
AreaChartMonotoneDemoFunction · 0.90
AreaChartStackedDemoFunction · 0.90
AreaChartControlledSmartFunction · 0.90
AreaChartDemoFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected