An open API service indexing awesome lists of open source software.

https://github.com/seonhyungjo/use-hammer

🔨 use-hammer : React Long Press Event
https://github.com/seonhyungjo/use-hammer

hammer hooks longpress react

Last synced: over 1 year ago
JSON representation

🔨 use-hammer : React Long Press Event

Awesome Lists containing this project

README

          


React useHammer Logo

React useHammer Hooks

[![NPM](https://img.shields.io/npm/v/use-hammer.svg)](https://www.npmjs.com/package/use-hammer) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save use-hammer
```

## Usage

```tsx
import React from 'react'
import useHammer from 'use-hammer'

const Example = () => {
const onHammer = useCallback(() => {
console.log('Long Press')
}, [])

const [hammerDown, hammerUp] = useHammer({onHammer, second:300})
return (

hammerDown()} onMouseUp={() => hammerUp()}/>
)
}
```

## API

### `useHammer`

| Prop | Type | Required | Description |
| :--- | :--- | :------: | :---------- |
| `onHammer` | Function | ✓ | Execute onHammer Function |
| `second` | number | | [Default:700ms] Millisecond |

## License

MIT © [snyung](https://github.com/snyung)

---

This hook is created using [create-react-hook](https://github.com/hermanya/create-react-hook).