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
Name | Type | Default | Note |
---|---|---|---|
target | HookTarget | - | 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
Name | Type | Default | Note |
---|---|---|---|
callback | (event: LongPressEvents) => void | - | The callback function to be invoked on long press |
options? | UseLongPressOptions | - | The options for the long press |
Returns
boolean