npm install --save use-hammer
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 (
<div className={"sample-div"} onMouseDown={()=> hammerDown()} onMouseUp={() => hammerUp()}/>
)
}
Prop | Type | Required | Description |
---|---|---|---|
onHammer |
Function | ✓ | Execute onHammer Function |
second |
number | [Default:700ms] Millisecond |
MIT © snyung
This hook is created using create-react-hook.