use-click-with-prevention
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

use-click-with-prevention

a custom react hook to prevent singleClick while doubleClick is fired


Build Status Version Downloads

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.1
    64
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.1
    64
  • 0.2.0
    0
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i use-click-with-prevention

Weekly Downloads

55

Version

0.2.1

License

MIT

Unpacked Size

6.68 kB

Total Files

8

Last publish

Collaborators

  • titan9389