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(() => {
// Your action here
console.log('Double tapped');
});
return <button {...bind}>Tap me</button>;
}
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.
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
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.