Long press hook
  • Introduction
  • Installation
  • Basics
  • Advanced
    • Definition
    • Callback
    • Options
      • Configuration
        • Events detection
        • Long press threshold
      • React events
        • Persisting event
        • Filtering events
      • Callbacks
        • Press started
        • On move
        • Press finished
        • Long press cancelled
      • Cancellation
        • Cancel outside element
        • Cancel on movement
    • Hook result / Bind function
      • Context
      • Handlers
  • Examples
    • Advanced usage example
    • Live examples
      • Version 3
      • Version 2 (deprecated)
      • Version 1 (deprecated)
  • Migration
    • V1 to V2
    • V2 to V3
    • ⚠️V3.1+
    • Change log
  • Contributions
    • ❤️Donations
    • Pull requests policy
  • Architectural Decisions
    • V1 and V2 deprecation
    • Moving to new repository
Powered by GitBook
On this page

Was this helpful?

  1. Advanced

Callback

Function called when long press is detected

PreviousDefinitionNextOptions

Last updated 1 year ago

Was this helpful?

useLongPress(callback [, options]): bindFn

Hook first parameter, callback, can be either function or null (if you want to disable the hook).

It is recommended (althought not neccessary) to keep callback memoized using useCallback because it is a direct dependency for memoized hook result.

const callback = useCallback(..., [...]);
const bind = useLongPress(callback, ...);

For more info about callback structure and it's parameters see .

callbacks