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
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/drawer-navigator.md
+12-4Lines changed: 12 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -206,6 +206,13 @@ function CustomDrawerContent(props) {
206
206
}
207
207
```
208
208
209
+
The `DrawerContentScrollView` component applies safe are insets automatically:
210
+
211
+
- On iOS, it sets `contentInsetAdjustmentBehavior="automatic"`
212
+
- On other platforms, it adjusts paddings of the scrollable content
213
+
214
+
You can override the default behavior by passing `contentInsetAdjustmentBehavior='never'` on iOS `contentContainerStyle` with custom paddings on other platforms.
215
+
209
216
To add additional items in the drawer, you can use the `DrawerItem` component:
@@ -667,12 +674,13 @@ Style object for the component wrapping the screen content.
667
674
668
675
#### `configureGestureHandler`
669
676
670
-
Callback to configure the underlying [gesture from `react-native-gesture-handler`](https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture). It receives the `gesture` object as an argument:
677
+
Callback to configure the underlying [pan gesture from `react-native-gesture-handler`](https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture). It receives the gesture configuration and should return the updated configuration:
A component that renders a button. In addition to [`PlatformPressable`](#platformpressable)'s props, it accepts following additional props:
@@ -721,6 +758,7 @@ A component that renders a button. In addition to [`PlatformPressable`](#platfor
721
758
-`filled`
722
759
-`color` - Color of the button. Defaults to the [theme](themes.md)'s primary color.
723
760
-`icon` - Icon to display before the label. It can be an icon object or a function that returns an icon object or a React element. See [Icons](icons.md) for more details.
761
+
-`loading` - Boolean which controls whether to show a loading indicator instead of the icon. The button is disabled while loading.
724
762
-`disabled` - Boolean which controls whether the button is disabled.
725
763
-`children` - Content to render inside the button. It must be a string or React element that can be nested inside a `Text` component.
726
764
@@ -734,7 +772,9 @@ It can be used to navigate between screens by specifying a screen name and param
734
772
</Button>
735
773
```
736
774
737
-
Or as a regular button:
775
+
When navigating to a screen this way, it automatically shows the loading indicator while the navigation transition is pending. You can pass `loading={false}` to disable the automatic loading indicator.
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/stack-navigator.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -640,6 +640,10 @@ This hook returns values related to the screen's animation. It contains the foll
640
640
641
641
See [Transparent modals](#transparent-modals) for an example of how to use this hook.
642
642
643
+
#### `useGestureHandler`
644
+
645
+
This hook returns the pan gesture for the current Stack screen, or `null` if gestures are not supported on the platform. It can be used to coordinate a custom gesture with the Stack's gesture using the APIs from [`react-native-gesture-handler`](https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture).
646
+
643
647
## Animations
644
648
645
649
You can specify the `animation` option to customize the transition animation for screens being pushed or popped.
@@ -847,6 +851,7 @@ Stack Navigator exposes various options to configure the transition animation wh
847
851
-`containerStyle` - Style for the container view wrapping the card.
848
852
-`cardStyle` - Style for the view representing the card.
849
853
-`overlayStyle` - Style for the view representing the semi-transparent overlay below
854
+
-`dimStyle` - Style for the dimming view on top of the card content.
850
855
-`shadowStyle` - Style for the view representing the card shadow.
851
856
852
857
The function receives the following properties in its argument:
@@ -1173,7 +1178,7 @@ import { TransitionSpecs } from '@react-navigation/stack';
1173
1178
1174
1179
-`forHorizontalIOS` - Standard iOS-style slide in from the right.
1175
1180
-`forVerticalIOS` - Standard iOS-style slide in from the bottom (used for modals).
1176
-
-`forModalPresentationIOS` - Standard iOS-style modal animation in iOS 13.
1181
+
-`forModalPresentationIOS` - Standard iOS-style modal animation.
1177
1182
-`forFadeFromBottomAndroid` - Standard Android-style fade in from the bottom for Android Oreo.
1178
1183
-`forRevealFromBottomAndroid` - Standard Android-style reveal from the bottom for Android Pie.
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/typescript.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -335,6 +335,30 @@ function Header() {
335
335
}
336
336
```
337
337
338
+
## Using typed links
339
+
340
+
The [`Link`](link.md), [`Button`](elements.md#button), and [`useLinkProps`](use-link-props.md) APIs are automatically type-checked based on the root navigator type.
341
+
342
+
By default, the `screen` and `params` props refer to a screen in the root navigator. To link to a screen in the current or a parent navigator, pass the name of the current or parent screen with the `in` prop, similar to the screen name accepted by `useNavigation`.
343
+
344
+
For example, suppose the `ArticleList` screen is in a stack nested under the `Feed` tab. The `Feed` tab is nested under the `Home` screen in the root navigator, alongside the `Settings` screen:
345
+
346
+
```tsx
347
+
function ArticleListScreen() {
348
+
return (
349
+
<>
350
+
{/* The root navigator is used by default */}
351
+
<Linkscreen="Settings">Go to Settings</Link>
352
+
353
+
{/* The navigator containing the Feed screen is used */}
If you render a dynamic navigator inside a static navigator, see [Mixing Static & Dynamic APIs](combine-static-with-dynamic.md#static-root-navigator-dynamic-nested-navigator) for the additional typing and linking configuration needed for the nested navigator.
The [`Link`](link.md), [`Button`](elements.md#button), and [`useLinkProps`](use-link-props.md) APIs are automatically type-checked based on the root navigator type.
588
+
589
+
By default, the `screen` and `params` props refer to a screen in the root navigator. To link to a screen in the current or a parent navigator, pass the name of the current or parent screen with the `in` prop, similar to the screen name accepted by `useNavigation`.
590
+
591
+
For example, suppose the `ArticleList` screen is in a stack nested under the `Feed` tab. The `Feed` tab is nested under the `Home` screen in the root navigator, alongside the `Settings` screen:
592
+
593
+
```tsx
594
+
function ArticleListScreen() {
595
+
return (
596
+
<>
597
+
{/* The root navigator is used by default */}
598
+
<Linkscreen="Settings">Go to Settings</Link>
599
+
600
+
{/* The navigator containing the Feed screen is used */}
When you pass the `options` to a `Screen` or `screenOptions` prop to a `Navigator` component, they are already type-checked and you don't need to do anything special. However, sometimes you might want to extract the options to a separate object, and you might want to annotate it.
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/upgrading-from-7.x.md
+82-2Lines changed: 82 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -726,6 +726,42 @@ Previously, the `gestureResponseDistance` option in Stack Navigator accepted an
726
726
+ gestureResponseDistance: 50
727
727
```
728
728
729
+
#### Stack and Drawer now use Gesture Handler 3
730
+
731
+
Stack and Drawer navigators now require `react-native-gesture-handler` 3. In addition to the [dependency change](#dependency-changes), APIs for customizing and accessing gestures have changed to match the new Gesture Handler API.
732
+
733
+
The [`configureGestureHandler`](drawer-navigator.md#configuregesturehandler) option in Drawer Navigator now receives and returns a gesture configuration object instead of a gesture builder:
734
+
735
+
```diff lang=js
736
+
- configureGestureHandler: (gesture) =>
737
+
- gesture.enableTrackpadTwoFingerGesture(false),
738
+
+ configureGestureHandler: (config) => ({
739
+
+ ...config,
740
+
+ enableTrackpadTwoFingerGesture: false,
741
+
+ }),
742
+
```
743
+
744
+
The utilities exported by Stack Navigator have also changed:
745
+
746
+
```diff lang=js
747
+
- import {
748
+
- GestureHandlerRefContext,
749
+
- useGestureHandlerRef,
750
+
- } from '@react-navigation/stack';
751
+
+ import {
752
+
+ GestureHandlerContext,
753
+
+ useGestureHandler,
754
+
+ } from '@react-navigation/stack';
755
+
```
756
+
757
+
The [`useGestureHandler`](stack-navigator.md#usegesturehandler) hook returns the pan gesture for the current Stack screen instead of a ref to the gesture handler.
758
+
759
+
#### Stack modal presentation has changed on iOS 26
760
+
761
+
The modal presentation in Stack Navigator has been updated to match the latest iOS design on iOS 26 and later. Modal screens now use rounded corners, and the screens underneath are scaled and dimmed.
762
+
763
+
This applies to screens using [`presentation: 'modal'`](stack-navigator.md#presentation) and the [`forModalPresentationIOS`](stack-navigator.md#cardstyleinterpolators) card style interpolator. If you use a custom card style interpolator for a similar presentation, it can now return a `dimStyle` to render a dimming view on top of the card content.
764
+
729
765
#### Material Top Tabs and `react-native-tab-view` have been updated to Material Design 3
730
766
731
767
##### The tab bar now uses the `primary` variant by default
@@ -1191,6 +1227,20 @@ It's still possible to use these hooks without passing the screen name, same as
1191
1227
1192
1228
See [`useNavigation`](use-navigation.md), [`useRoute`](use-route.md), and [`useNavigationState`](use-navigation-state.md) for more details.
1193
1229
1230
+
### Links can target screens in the current or a parent navigator
1231
+
1232
+
The [`useLinkProps`](use-link-props.md), [`Link`](link.md), and [`Button`](elements.md#button) APIs now accept an [`in`](use-link-props.md#in) prop. It specifies the name of the current or parent screen whose navigator contains the target screen.
1233
+
1234
+
For example, a screen nested in the `Home` tab can link to the `Settings` tab in the parent tab navigator:
1235
+
1236
+
```js
1237
+
<Link in="Home"screen="Settings">
1238
+
Go to Settings
1239
+
</Link>
1240
+
```
1241
+
1242
+
This is similar to how [typed hooks accept the name of the screen](#common-hooks-now-accept-name-of-the-screen). But unlike typed hooks, navigation from `Link` using the `screen` and `params` props doesn't bubble up to parent navigators.
1243
+
1194
1244
### New entry can be added to history stack with `pushParams` action
1195
1245
1196
1246
The `pushParams` action updates the params and pushes a new entry to the history stack:
In addition, new `SFSymbol` and `MaterialSymbol` components are exported from `@react-navigation/native` to render these icons directly.
1574
1624
1625
+
The new [`PlatformIcon`](elements.md#platformicon) component from `@react-navigation/elements` can render an icon object directly. It renders an image, SF Symbol, or Material Symbol based on the icon object:
### `react-native-tab-view` now supports a `renderAdapter` prop for custom adapters
@@ -1607,9 +1671,25 @@ export default function TabViewExample() {
1607
1671
1608
1672
You can also create your own custom adapter by implementing the required interface. See the [`react-native-tab-view` docs](tab-view.md) for more information.
1609
1673
1610
-
### `Button` from `@react-navigation/elements` now supports disabled state, icons and React elements
1674
+
### `Button` from `@react-navigation/elements` now supports more options
1675
+
1676
+
The [`Button`](elements.md#button) component now supports loading and disabled states. The `loading` prop shows a loading indicator in place of the icon and disables interaction:
1611
1677
1612
-
The [`Button`](elements.md#button) component now supports a disabled state.
1678
+
```js
1679
+
<Button loading={isLoading} onPress={submit}>
1680
+
Submit
1681
+
</Button>
1682
+
```
1683
+
1684
+
When the button navigates to a screen, it automatically shows the loading indicator while the navigation transition is pending. You can pass `loading={false}` to disable the automatic loading indicator.
1685
+
1686
+
The `disabled` prop disables interaction and applies a disabled style to the button:
1687
+
1688
+
```js
1689
+
<Button disabled={isDisabled} onPress={submit}>
1690
+
Submit
1691
+
</Button>
1692
+
```
1613
1693
1614
1694
It also accepts an `icon` prop to show an icon alongside the button label:
@@ -64,6 +78,20 @@ If you want to navigate to a nested screen, you can pass the name of the `screen
64
78
</LinkButton>
65
79
```
66
80
81
+
### `in`
82
+
83
+
By default, the link targets a screen in the root navigator. You can pass the name of the current or parent screen whose navigator contains the target screen with the `in` prop.
84
+
85
+
For example, if the current screen is nested in the `Home` tab, you can link to the `Settings` tab in the parent tab navigator:
86
+
87
+
```js
88
+
<LinkButton in="Home"screen="Settings">
89
+
Go to Settings
90
+
</LinkButton>
91
+
```
92
+
93
+
This is similar to how [useNavigation](use-navigation.md) accepts the current screen or any of its parent screens. But unlike navigating with `useNavigation`, navigation from `Link` using the `screen` and `params` props doesn't bubble up to parent navigators.
94
+
67
95
### `action`
68
96
69
97
Sometimes we want a different behavior for in-page navigation, such as `replace` instead of `navigate`. We can use the `action` prop to customize it:
@@ -88,7 +116,9 @@ function Home() {
88
116
}
89
117
```
90
118
91
-
The `screen` and `params` props can be omitted if the `action` prop is specified. In that case, we recommend specifying the `href` prop as well to ensure that the link is accessible.
119
+
The action gets dispatched to the current navigator and can bubble upto a parent navigator similar to dispatching the action with [navigation.dispatch](navigation-object.md#dispatch).
120
+
121
+
The `screen` and `params` props can be omitted if the `action` prop is specified. In that case, we recommend specifying the `href` prop as well to ensure that the link is accessible. The `in` prop is not supported when only the `action` prop is specified.
0 commit comments