Skip to content

useLongPress ​

sensors
test coverage
Last changed: 17 days ago

Hook that defines the logic when long pressing an element

typescript
import { useLongPress } from '@siberiacancode/reactuse';

Usage ​

typescript
const pressed = useLongPress(ref, () => console.log('callback'));
// or
const { ref, pressed } = useLongPress(() => console.log('callback'));

Demo ​

Api ​

Parameters

NameTypeDefaultNote
targetHookTarget-The target element to be long pressed
callback(event: LongPressEvents) => void-The callback function to be invoked on long press
options?UseLongPressOptions-The options for the long press

Returns

boolean

Parameters

NameTypeDefaultNote
callback(event: LongPressEvents) => void-The callback function to be invoked on long press
options?UseLongPressOptions-The options for the long press

Returns

boolean

Source ​

Source • Demo

Contributors ​

Avatardebabin
Avatarhywax

Released under the MIT License.