Skip to content

diogomoretti/use-double-click-hook

Repository files navigation

Use Double Click Hook

A React hook to detect double clicks.

✨ View Demo ➔


GitHub Actions Workflow Status NPM Version

Installation

Using npm:

npm install use-double-click-hook

Using yarn:

yarn add use-double-click-hook

Using pnpm:

pnpm add use-double-click-hook

Usage

import { useDoubleClick } from 'use-double-click-hook';

const MyComponent = () => {
  const handleClick = useDoubleClick({
    onDoubleClick: () => {
      console.log('Double click detected!');
    }
  });

  return <div onClick={handleClick}>Double Click Me</div>;
};

Options

parameter type default description required
onSuccess function () => {} A function to be called when a double click is detected. Yes
delay number 300 The delay in milliseconds between the first and second click. No

License

MIT License