Sha256: 29ac61bc80ce7133b42b598812b3a15b8d3f8b44046c26f79d74a8c51ddea6a8
Contents?: true
Size: 509 Bytes
Versions: 3
Compression:
Stored size: 509 Bytes
Contents
import { useEffect, useState } from 'react' export const useWindowSize = () => { const [size, setSize] = useState({ width: window.innerWidth, height: window.innerHeight, }) useEffect(() => { const handleResize = () => { setSize({ width: window.innerWidth, height: window.innerHeight, }) } window.addEventListener('resize', handleResize) handleResize() return () => window.removeEventListener('resize', handleResize) }, []) return size }
Version data entries
3 entries across 3 versions & 1 rubygems