import { useEffect } from 'react' ; const useEventListener = ( ref , type , listener , ... options ) => { const cur = ref . current ; useEffect ( ( ) => { if ( cur ) { cur . addEventListener ( type , listener , ... options ) ; } return ( ) => { if ( cur ) { cur . removeEventListener ( type , listener , ... options ) ; } } ; } , [ ref , ref . current , type , listener , options ] ) ; } ; export default useEventListener ;