import { useRef } from "react" ; export function useDoubleTap ( callback , timeout = 300 ) { const prevTapTimestamp = useRef ( 0 ) ; return ( e ) => { const tapTimestamp = performance . now ( ) ; if ( tapTimestamp - prevTapTimestamp . current <= timeout ) { callback ( e ) ; prevTapTimestamp . current = 0 ; } else { prevTapTimestamp . current = tapTimestamp ; } } ; }