import { useEventListener } from './use-event-listener' ; export function useSelectionChange ( handler , ref ? ) { useEventListener ( 'selectstart' , ( ) => { ref ?. addEventListener ( 'keyup' , handler ) ; ref ?. addEventListener ( 'mouseup' , handler ) ; } , ref ) ; return ( ) => { if ( handler ) { ref ?. removeEventListener ( 'keyup' , handler ) ; ref ?. removeEventListener ( 'mouseup' , handler ) ; } } ; }