import { useEffect , useState } from "../lib/prehook/prehook" ; const getWindowSize = ( ) => ( { width : window . innerWidth , height : window . innerHeight } ) ; /**
 * We export our custom hook to be usable in any component.
 * This will help us to know when window is updated and which is the current size.
 */ export function useWindowSize ( ) { const sizeState = useState ( getWindowSize ( ) ) ; function resizeHandler ( ) { sizeState ( getWindowSize ( ) ) ; } useEffect ( { mount : ( ) => window . addEventListener ( 'resize' , resizeHandler ) , unmount : ( ) => window . removeEventListener ( 'resize' , resizeHandler ) } ) ; return sizeState ; }