use-click-with-prevention
a custom react hook to prevent singleClick while doubleClick is fired
Table of Contents
- [🐛 Bugs](#-bugs)
- [💡 Feature requests](#-feature-requests)
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>
)
}