import * as React from 'react' ; import useLatest from 'use-latest' ; export { default as useComposedRef } from 'use-composed-ref' ; export const useWindowResizeListener = ( listener ) => { const latestListener = useLatest ( listener ) ; React . useLayoutEffect ( ( ) => { const handler = ( event ) => { latestListener . current ( event ) ; } ; window . addEventListener ( 'resize' , handler ) ; return ( ) => { window . removeEventListener ( 'resize' , handler ) ; } ; } , [ ] ) ; } ;