use-click-with-prevention

a custom react hook to prevent singleClick while doubleClick is fired

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
use-click-with-prevention
200.2.12 years ago2 years agoMinified + gzip package size for use-click-with-prevention in KB

Readme

use-click-with-prevention

a custom react hook to prevent singleClick while doubleClick is fired


Build Status Version Downloads

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>
  )
}

🐛 Bugs

Please file an issue for bugs, missing documentation, or unexpected behavior.

LICENSE

MIT