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
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
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() {
|
||||
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
|
||||
return React.useSyncExternalStore(
|
||||
subscribe,
|
||||
() => window.matchMedia(MOBILE_QUERY).matches,
|
||||
() => false
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user