No changes.

This commit is contained in:
gpt-engineer-app[bot]
2025-03-16 06:04:18 +00:00
parent 55296641c9
commit 2f926e7a65
5 changed files with 27 additions and 10 deletions

View File

@@ -1,19 +1,25 @@
import * as React from "react"
const MOBILE_BREAKPOINT = 768
export function useIsMobile() {
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
const [isMobile, setIsMobile] = React.useState<boolean>(false)
React.useEffect(() => {
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
const onChange = () => {
const checkMobile = () => {
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
}
mql.addEventListener("change", onChange)
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
return () => mql.removeEventListener("change", onChange)
// 초기 확인
checkMobile()
// 리사이즈 이벤트 리스너 추가
window.addEventListener('resize', checkMobile)
// 클린업 함수
return () => window.removeEventListener('resize', checkMobile)
}, [])
return !!isMobile
return isMobile
}