UNPKG

@rakhimgaliyev/react-bottom-sheet

Version:

Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it.

25 lines (18 loc) 498 B
import { useEffect, useState } from 'react' export const useWindowSize = () => { const getSize = () => { return { width: window.innerWidth, height: window.innerHeight } } const [windowSize, setWindowSize] = useState(getSize) useEffect(() => { const handleResize = () => { setWindowSize(getSize()) } window.addEventListener('resize', handleResize) return () => window.removeEventListener('resize', handleResize) }, []) return windowSize }