Skip to content

Commit a06375e

Browse files
committed
Document sheetDetentChange and gestureCancel events for native stack
1 parent 715be9e commit a06375e

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

versioned_docs/version-7.x/native-stack-navigator.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,43 @@ React.useEffect(() => {
13521352
}, [navigation]);
13531353
```
13541354

1355+
#### `gestureCancel`
1356+
1357+
This event is fired when the swipe back gesture is canceled. Only supported on iOS.
1358+
1359+
Example:
1360+
1361+
```js
1362+
React.useEffect(() => {
1363+
const unsubscribe = navigation.addListener('gestureCancel', (e) => {
1364+
// Do something
1365+
});
1366+
1367+
return unsubscribe;
1368+
}, [navigation]);
1369+
```
1370+
1371+
#### `sheetDetentChange`
1372+
1373+
This event is fired when the screen has [`presentation`](#presentation) set to `formSheet` and the sheet detent changes.
1374+
1375+
Event data:
1376+
1377+
- `e.data.index` - Index of the current detent in the `sheetAllowedDetents` array.
1378+
- `e.data.stable` - Boolean indicating whether the sheet is being dragged or settling. Only supported on Android. On iOS, this is always `true`.
1379+
1380+
Example:
1381+
1382+
```js
1383+
React.useEffect(() => {
1384+
const unsubscribe = navigation.addListener('sheetDetentChange', (e) => {
1385+
// Do something
1386+
});
1387+
1388+
return unsubscribe;
1389+
}, [navigation]);
1390+
```
1391+
13551392
### Helpers
13561393

13571394
The native stack navigator adds the following methods to the navigation object:

versioned_docs/version-8.x/native-stack-navigator.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ React.useEffect(() => {
13571357

13581358
#### `gestureCancel`
13591359

1360-
This event is fired when a swipe back gesture is canceled on iOS.
1360+
This event is fired when the swipe back gesture is canceled. Only supported on iOS.
13611361

13621362
Example:
13631363

@@ -1371,32 +1371,27 @@ React.useEffect(() => {
13711371
}, [navigation]);
13721372
```
13731373

1374-
Only supported on iOS.
1375-
13761374
#### `sheetDetentChange`
13771375

1378-
This event is fired when a screen with `presentation: 'formSheet'` changes its detent.
1376+
This event is fired when the screen has [`presentation`](#presentation) set to `formSheet` and the sheet detent changes.
13791377

13801378
Event data:
13811379

1382-
- `e.data.index` - The current detent index in the `sheetAllowedDetents` array.
1383-
- `e.data.stable` - On Android, `false` means the user is dragging the sheet or it is settling. On iOS, this is always `true`.
1380+
- `e.data.index` - Index of the current detent in the `sheetAllowedDetents` array.
1381+
- `e.data.stable` - Boolean indicating whether the sheet is being dragged or settling. Only supported on Android. On iOS, this is always `true`.
13841382

13851383
Example:
13861384

13871385
```js
13881386
React.useEffect(() => {
13891387
const unsubscribe = navigation.addListener('sheetDetentChange', (e) => {
1390-
console.log('Detent index:', e.data.index);
1391-
console.log('Is stable:', e.data.stable);
1388+
// Do something
13921389
});
13931390

13941391
return unsubscribe;
13951392
}, [navigation]);
13961393
```
13971394

1398-
Only supported on Android and iOS.
1399-
14001395
### Helpers
14011396

14021397
The native stack navigator adds the following methods to the navigation object:

0 commit comments

Comments
 (0)