Double tap hook
  • Introduction
  • Installation
  • Basics
  • Advanced
    • Definition
    • Callback
    • Threshold
    • Options
      • Callbacks
        • Single tap
    • Hook result / Bind object
      • Handlers
  • Examples
    • Live demo
      • Version 1
  • Migration
    • Change log
Powered by GitBook
On this page

Was this helpful?

  1. Advanced

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, ...);
PreviousDefinitionNextThreshold

Last updated 1 year ago

Was this helpful?