import { useState, useEffect } from 'react' import { Dimensions } from 'react-native' import { getScreenSize } from 'utils/responsive' const INITIAL_WINDOW = getScreenSize() const useWindowDimensions = () => { const [window, setWindow] = useState(INITIAL_WINDOW) useEffect(() => { const sub = Dimensions.addEventListener('change', ({ window }) => { setWindow(window) }) // @ts-ignore (react-native types package is outdated) return () => sub?.remove() }, []) return window } export default useWindowDimensions