Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
use-double-click
Advanced tools
A simple React hook for differentiating single and double clicks on the same component.
use-double-click is a simple React hook for differentiating single and double clicks on the same component.
Check out the demo on Codesandbox
onDoubleClick()
?When you double click on an element, onClick()
fires twice alongside your single onDoubleClick()
callback. This effect isn't desirable when a single click and a double click have different functions!
useDoubleClick()
waits within a latency window after a click for a secondary click, and only after this period either the onSingleClick
or onDoubleClick()
callback will fire a single time.
yarn add use-double-click
import { useRef } from 'react';
import useDoubleClick from 'use-double-click';
const Button = () => {
const buttonRef = useRef();
useDoubleClick({
onSingleClick: e => {
console.log(e, 'single click');
},
onDoubleClick: e => {
console.log(e, 'double click');
},
ref: buttonRef,
latency: 250
});
return <button ref={buttonRef}>Click Me</button>
}
Prop | Description |
---|---|
onSingleClick | A callback function for single click events |
onDoubleClick | A callback function for double click events |
ref | Dom node to watch for double clicks |
latency | The amount of time (in milliseconds) to wait before differentiating a single from a double click |
MIT © Tim Ellenberger
[1.0.5] - 2019-08-6
Add testing suite
FAQs
A simple React hook for differentiating single and double clicks on the same component.
The npm package use-double-click receives a total of 3,959 weekly downloads. As such, use-double-click popularity was classified as popular.
We found that use-double-click demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.