usePressHold

Executes callback when the user presses and holds ref for a specified duration. Additional options can be provided to customize the gesture.

  • @param ref - The element to attach the gesture to.
  • @param callback - Function to execute when gesture is complete.
  • @param options - Configurable options
  • @returns void

Example

const ref = useRef<HTMLDivElement>(null);
 
usePressHold(ref, () => {
  console.log('Press and hold gesture complete!');
}, { duration: 1000 });
 
return <div ref={ref} />;