Expo UI and Router for iOSExpo SDK 57 and later, iOS only
Modifiers

onLongPressGesture

Adds a long press gesture recognizer.

onLongPressGesture(handler, minimumDuration)

ParameterTypeDescription
handler() => voidFunction to call when long pressed.
minimumDuration(optional)numberMinimum duration for long press (default: 0.5s)

Adds a long press gesture recognizer.

Returns: ModifierConfig

Works with

You can add onLongPressGesture to any view. It changes what you see on 31 of the 39 components.

Needs care

It works on these components, but not in the way that you may expect.

ComponentWhat to know
VStackTouches on the empty space between children are not detected. Add contentShape('rectangle') before this modifier.
HStackTouches on the empty space between children are not detected. Add contentShape('rectangle') before this modifier.
ZStackTouches on the empty space between children are not detected. Add contentShape('rectangle') before this modifier.
LazyVStackTouches on the empty space between children are not detected. Add contentShape('rectangle') before this modifier.
LazyHStackTouches on the empty space between children are not detected. Add contentShape('rectangle') before this modifier.
ScrollViewPut the handler on a child view. A gesture on the scroll view itself can stop the scroll.

No visible effect

These components accept it, but you see no change.

ComponentWhy nothing happens
SpacerIn SDK 57, Spacer does not send modifier events to JavaScript, so the handler does not run.
DividerIn SDK 57, Divider does not send modifier events to JavaScript, so the handler does not run.
SliderIn SDK 57, Slider does not send modifier events to JavaScript, so the handler does not run.
MenuIn SDK 57, Menu does not send modifier events to JavaScript, so the handler does not run.
ContextMenuIn SDK 57, ContextMenu does not send modifier events to JavaScript, so the handler does not run.
ProgressViewIn SDK 57, ProgressView does not send modifier events to JavaScript, so the handler does not run.
GaugeIn SDK 57, Gauge does not send modifier events to JavaScript, so the handler does not run.
AccessoryWidgetBackgroundIn SDK 57, AccessoryWidgetBackground does not send modifier events to JavaScript, so the handler does not run.

Sources

The original Expo docs for this page:

On this page