use-click-with-prevention
v0.2.1
Published
a custom react hook to prevent singleClick while doubleClick is fired
Downloads
160
Maintainers
Readme
Table of Contents
Installation
This module is distributed via NPM which is bundled with NodeJS and should be installed as one of your project's dependencies:
npm install use-click-with-prevention
Usage
import useClickWithPrevention from 'use-click-with-prevention'
const MyComponent = () => {
const singleClick = () => {
// do something
}
const doubleClick = () => {
// do something else
}
// useClickWithPreventio 3rd argument optional = delay: number
const [onClick,onDoubleClick] = useClickWithPrevention(singleClick,doubleClick [,delay]);
return (
<div>
<button onClick={onClick} onDoubleClick={onDoubleClick}>Click Me!</button>
</div>
)
}
🐛 Bugs
Please file an issue for bugs, missing documentation, or unexpected behavior.
LICENSE
MIT