Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/llms-txt-hub / packages/design-system/hooks/use-mobile.tsx |
| Date | Not specified in source |
| Repository | Janady13/llms-txt-hub |
| Revision | e0f4bf978d4df168369c7601d9c5f5ea89e84377 |
| Branch | main |
| Path or archive member | packages/design-system/hooks/use-mobile.tsx |
| Original SHA-256 | 1b43441b273aa21c1e74fefa774d5a7cb50068e5d4c192a8f63b9c95c5580431 |
| Git blob SHA | 4331d5c562002281036ddd480a20d854f1880e9b |
| Reading-copy SHA-256 | 1b43441b273aa21c1e74fefa774d5a7cb50068e5d4c192a8f63b9c95c5580431 |
Recovered source transcript
Download complete source text ↓20 lines · 0.6 KB
import * as React from 'react'
const MOBILE_BREAKPOINT = 768
export function useIsMobile() {
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
React.useEffect(() => {
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
const onChange = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
}
mql.addEventListener('change', onChange)
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
return () => mql.removeEventListener('change', onChange)
}, [])
return !!isMobile
}