blob: fa79cc429fcb0b008138f112cdc28f9d48ffc955 (
plain) (
tree)
|
|
import { useEffect, useState } from 'react'
function useWindowWidth() {
const [width, setWidth] = useState(window.innerWidth)
useEffect(() => {
const handleResize = () => setWidth(window.innerWidth)
window.addEventListener('resize', handleResize)
return () => window.removeEventListener('resize', handleResize)
}, [])
return width
}
export default useWindowWidth
|