A React hook to detect double clicks.
✨ View Demo ➔
Using npm:
npm install use-double-click-hook
Using yarn:
yarn add use-double-click-hook
Using pnpm:
pnpm add use-double-click-hook
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>;
};
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 |