Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
use-double-tap
Advanced tools
React hook for handling double tap on mobile devices
npm install --save use-double-tap
or
yarn add use-double-tap
import React from 'react';
import { useDoubleTap } from 'use-double-tap';
const Example = () => {
const bind = useDoubleTap((event) => {
// Your action here
console.log('Double tapped');
});
return <button {...bind}>Tap me</button>;
}
export default Example;
You can also manually specify time threshold for capturing double tap event (default: 300ms).
useDoubleTap(() => {
// Your action here
}, 500);
In the example above, second tap must occur within 500ms period to register double tap.
Supplied as third argument.
useDoubleTap(() => {
// Actions on double tap
}, 300, {
// Options here
})
List of possible options:
Option | Type | Description |
---|---|---|
onSingleTap | Function | Callback for handling case when double tap is not triggered, because of capture timeout. For example if threshold parameter is 300ms and second tap occurs after 400msthen onSingleTap is triggered after capture interval (300ms) expires. |
If you pass falsy value as callback (like null
) double tap will not bind to the component.
useDoubleTap(null);
This allows you to dynamically control if event should be bound. For example:
const bind = useDoubleTap(isMobile ? () => {
console.log('Double tapped');
} : null);
This hook internally use onClick
event to detect double tap, so be careful not to override your existing event listener.
This is where disabling listener binding may come handy - you can use double tap detection only when necessary.
onClick
?Because it leverages built in event listener which can also detect mobile tap event.
This way we can get rid of complicated edge cases when combining onTouchStart onTouchEnd onTouchCancel onTouchMove
events.
Also this approach greatly reduce package size as well as increase speed and flexibility.
MIT © minwork
FAQs
React hook for handling double tap on mobile devices
The npm package use-double-tap receives a total of 3,199 weekly downloads. As such, use-double-tap popularity was classified as popular.
We found that use-double-tap 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.