"use client" | |
import { useState, useEffect } from "react" | |
export function useIsMobile() { | |
const [isMobile, setIsMobile] = useState(false) | |
useEffect(() => { | |
const checkIsMobile = () => { | |
setIsMobile(window.innerWidth < 768) | |
} | |
checkIsMobile() | |
window.addEventListener("resize", checkIsMobile) | |
return () => window.removeEventListener("resize", checkIsMobile) | |
}, []) | |
return isMobile | |
} | |
// Export both named and default for compatibility | |
export const useMobile = useIsMobile | |
export default useIsMobile | |