Callback

Function called when element is double tapped

useDoubleTap(callback [, threshold] [, options]): bindObj

Hook first parameter, callback, can be either function or null (if you want to disable the hook).

This allows you to dynamically control if event should be bound. For example:

const bind = useDoubleTap(isMobile ? () => {
  console.log('Double tapped');
} : null);

It is recommended (althought not neccessary) to keep callback memoized using useCallback because it will be a direct dependency for memoized hook result.

const callback = useCallback(..., [...]);
const bind = useDoubleTap(callback, ...);

Last updated