Callbacks

Long press lifecycle callbacks

Structure

All callbacks (including main callback function) has the same structure.

Pseudocode
callbackFn(event, meta): void
TypeScript
type LongPressCallback<Target extends Element = Element, Context = unknown> = (
  event: LongPressEvent<Target>,
  meta: LongPressCallbackMeta<Context>
) => void

As a first argument callback receives React event from a proper handler (e.g. onMouseDown) and as second receives meta object with following structure:

Pseudocode

Pseudocode
{ [context: any], [reason: string] }
TypeScript
export type LongPressCallbackMeta<Context = unknown> = { 
    context?: Context; 
    reason?: LongPressCallbackReason 
};

Both object properties are optional.

Context

context will be present if you pass it to bind function. See context for more info.

Reason

reason will be present in onCancel callback to indicate why long press was cancelled.

Here is a list of all possible reason values

Press startedOn movePress finishedLong press cancelled

Last updated

Was this helpful?