You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Either view styles or a function that receives a boolean reflecting whether the component is currently pressed and returns view styles.
47
+
48
+
### onPress
49
+
50
+
```ts
51
+
onPress?:null| ((event:PressableEvent) =>void);
52
+
```
53
+
54
+
Called after [`onPressOut`](#onpressout) when a single tap gesture is detected. Details about the event object can be found in the [PressableEvent](#pressableevent) section below.
55
+
56
+
### onPressIn
57
+
58
+
```ts
59
+
onPressIn?:null| ((event:PressableEvent) =>void);
60
+
```
61
+
62
+
Called before `onPress` when a touch is engaged. Details about the event object can be found in the [PressableEvent](#pressableevent) section below.
Called before `onPress` when a touch is released (before [`onPress`](#onpress)). Details about the event object can be found in the [PressableEvent](#pressableevent) section below.
31
71
32
-
either children or a render function that receives a boolean reflecting whether
Called immediately after pointer has been down for at least [`delayLongPress`](#delaylongpress) milliseconds.
36
79
37
-
either view styles or a function that receives a boolean reflecting whether
38
-
the component is currently pressed and returns view styles.
80
+
After `onLongPress` has been called, [`onPressOut`](#onpressout) will be called as soon as the pointer is lifted and [`onPress`](#onpress) will not be called at all.
39
81
40
-
### `onPress`
82
+
### cancelable
83
+
84
+
```ts
85
+
cancelable?:null|boolean;
86
+
```
41
87
42
-
called after `onPressOut` when a single tap gesture is detected.
88
+
Whether a press gesture can be interrupted by a parent gesture such as a scroll event. Defaults to `true`.
additional distance outside of the view (or `hitSlop` if present) in which a touch is considered a
95
-
press before `onPressOut` is triggered.
173
+
Enables the Android [ripple](https://developer.android.com/reference/android/graphics/drawable/RippleDrawable) effect and configures its color, radius and other parameters.
96
174
97
-
Accepts values of type `number` or [`Rect`](https://reactnative.dev/docs/rect)
175
+
Accepts values of type [`RippleConfig`](https://reactnative.dev/docs/pressable#rippleconfig).
98
176
99
-
### `android_disableSound` (Android only)
177
+
### testOnly_pressed
100
178
101
-
if `true`, doesn't play system sound on touch.
179
+
```ts
180
+
testOnly_pressed?:null|boolean;
181
+
```
102
182
103
-
### `android_ripple` (Android only)
183
+
Used only for documentation or testing (e.g. snapshot testing).
104
184
105
-
enables the Android ripple effect and configures its color, radius and other parameters.
185
+
### unstable_pressDelay
106
186
107
-
Accepts values of type [`RippleConfig`](https://reactnative.dev/docs/pressable#rippleconfig)
187
+
```ts
188
+
unstable_pressDelay?:number|undefined;
189
+
```
108
190
109
-
### `testOnly_pressed`
191
+
Duration (in milliseconds) to wait after press down before calling [`onPressIn`](#onpressin).
110
192
111
-
used only for documentation or testing (e.g. snapshot testing).
193
+
## PressableEvent
112
194
113
-
### `unstable_pressDelay`
195
+
All `Pressable` callbacks receive an event object as a parameter, which is of type `PressableEvent` and has the following structure:
114
196
115
-
duration (in milliseconds) to wait after press down before calling `onPressIn`.
See the full [pressable example](https://github.com/software-mansion/react-native-gesture-handler/blob/main/apps/common-app/src/new_api/pressable/index.tsx) from `GestureHandler` example app.
See the full example in [Gesture Handler repository](https://github.com/software-mansion/react-native-gesture-handler/blob/main/apps/common-app/src/legacy/v2_api/pressable/index.tsx).
122
217
123
-
```js
218
+
<CollapsibleCode
219
+
label="Show full example"
220
+
expandedLabel="Hide full example"
221
+
lineBounds={[5, 20]}
222
+
src={`
124
223
import { View, Text, StyleSheet } from 'react-native';
0 commit comments