useLongPress ​
Hook that defines the logic when long pressing an element
typescript
import { useLongPress } from '@siberiacancode/reactuse';
Usage ​
typescript
const [bind, longPressing] = useLongPress(() => console.log('callback'));
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
target | Target | - | The target element to be long pressed |
callback | (event: Event) => void | - | The callback function to be invoked on long press |
options.threshold? | number | 400 | The threshold time in milliseconds |
options.onStart? | (event: Event) => void | - | The callback function to be invoked on long press start |
options.onFinish? | (event: Event) => void | - | The callback function to be invoked on long press finish |
options.onCancel? | (event: Event) => void | - | The callback function to be invoked on long press cancel |