Skip to content

useLongPress ​

Category
Sensors

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

NameTypeDefaultNote
targetTarget-The target element to be long pressed
callback(event: Event) => void-The callback function to be invoked on long press
options.threshold?number400The 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

Contributors ​

Source • Demo