Files
nextjs-vercel/hooks/use-mobile.ts
Rami Bitar d5e463a665 Strip template artifacts and fix lint errors
Remove npm lockfile, unused create-next-app SVGs, project-specific
next.config workarounds, and the unused @remixicon/react and date-fns deps.

Replace three set-state-in-effect patterns with useSyncExternalStore in
use-mobile, DialogPortal, and Carousel; the carousel change also fixes a
leaked reInit listener. yarn lint and yarn build are clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K8PmydbW6A1S2Tw3SFc3Cg
2026-07-23 19:24:23 -04:00

19 lines
492 B
TypeScript

import * as React from "react"
const MOBILE_BREAKPOINT = 768
const MOBILE_QUERY = `(max-width: ${MOBILE_BREAKPOINT - 1}px)`
function subscribe(onStoreChange: () => void) {
const mql = window.matchMedia(MOBILE_QUERY)
mql.addEventListener("change", onStoreChange)
return () => mql.removeEventListener("change", onStoreChange)
}
export function useIsMobile() {
return React.useSyncExternalStore(
subscribe,
() => window.matchMedia(MOBILE_QUERY).matches,
() => false
)
}