Skip to content

Commit b81b4cb

Browse files
committed
Include updates for deep links, stack animations etc.
1 parent 5118090 commit b81b4cb

7 files changed

Lines changed: 320 additions & 12 deletions

File tree

versioned_docs/version-8.x/configuring-links.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,100 @@ const state = {
758758

759759
</details>
760760

761+
## Matching multiple path segments
762+
763+
A path param normally matches one path segment. For example, the path `user/:id` will match `/user/jane` but not `/user/jane/settings`.
764+
765+
If you want to match multiple segments, you can add `+` or `*` suffix after the param name.
766+
767+
- `+` matches one or more segments. For example, `files/:parts+` will match `/files/a` and `/files/a/b`.
768+
- `*` matches zero or more segments. For example, `files/:parts*` will match `/files`, `/files/a` and `/files/a/b`.
769+
770+
<ConfigTabs>
771+
<TabItem value="static">
772+
773+
```js
774+
const RootStack = createStackNavigator({
775+
screens: {
776+
Files: {
777+
screen: FilesScreen,
778+
// Matches /files/a and /files/a/b
779+
linking: 'files/:parts+',
780+
},
781+
OptionalFiles: {
782+
screen: OptionalFilesScreen,
783+
// Also matches /optional-files
784+
linking: 'optional-files/:parts*',
785+
},
786+
},
787+
});
788+
```
789+
790+
</TabItem>
791+
<TabItem value="dynamic">
792+
793+
```js
794+
const config = {
795+
screens: {
796+
// Matches /files/a and /files/a/b
797+
Files: 'files/:parts+',
798+
// Also matches /optional-files
799+
OptionalFiles: 'optional-files/:parts*',
800+
},
801+
};
802+
```
803+
804+
</TabItem>
805+
</ConfigTabs>
806+
807+
When using `+` or `*`, the route params will contain a string with the matched segment, e.g. for `/files/a/b`, the `parts` param will be `a/b`. It can be an empty string if the param is optional and not present in the URL.
808+
809+
If you want to get the segments as an array, you can use a custom `parse` [function](#using-functions) or [schema](#using-standard-schema):
810+
811+
<ConfigTabs>
812+
<TabItem value="static">
813+
814+
```js
815+
const RootStack = createStackNavigator({
816+
screens: {
817+
Files: {
818+
screen: FilesScreen,
819+
linking: {
820+
path: 'files/:parts+',
821+
parse: {
822+
parts: (parts) => parts.split('/'),
823+
},
824+
stringify: {
825+
parts: (parts) => parts.join('/'),
826+
},
827+
},
828+
},
829+
},
830+
});
831+
```
832+
833+
</TabItem>
834+
<TabItem value="dynamic">
835+
836+
```js
837+
const config = {
838+
screens: {
839+
Files: {
840+
path: 'files/:parts+',
841+
parse: {
842+
parts: (parts) => parts.split('/'),
843+
},
844+
stringify: {
845+
parts: (parts) => parts.join('/'),
846+
},
847+
},
848+
},
849+
};
850+
```
851+
852+
</TabItem>
853+
</ConfigTabs>
854+
761855
## Handling unmatched routes or 404
762856

763857
If your app is opened with an invalid URL, most of the times you'd want to show an error page with some information. On the web, this is commonly known as 404 - or page not found error.

versioned_docs/version-8.x/icons.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ The component accepts the following props:
337337
<source src="/assets/icons/sf-symbol-magic-replace.mp4"></source>
338338
</video>
339339
340+
- `style`
341+
342+
Plain style object for the symbol's native view. If you need to pass a style array, use `StyleSheet.flatten` to convert it to a plain style object.
343+
340344
## Material Symbols
341345

342346
Material Symbols is a library of over 2,500 glyphs designed to integrate well with Material Design on Android.
@@ -451,6 +455,10 @@ The component accepts the following props:
451455

452456
The available weights depend on which weights are included in the bundle. If the specified weight is not included, it will throw an error.
453457

458+
- `style`
459+
460+
Plain style object for the symbol's native view. If you need to pass a style array, use `StyleSheet.flatten` to convert it to a plain style object.
461+
454462
## Images
455463

456464
React Navigation also supports using images as icons. It supports the same formats as React Native's [`Image`](https://reactnative.dev/docs/image) component.

versioned_docs/version-8.x/link.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,15 @@ function Home() {
2626
2727
If you want to use your own custom link component, you can use [`useLinkProps`](use-link-props.md) instead.
2828
29-
The `Link` component accepts the [same props as `useLinkProps`](use-link-props.md#options).
29+
The `Link` component accepts the [same props as `useLinkProps`](use-link-props.md#options), along with the following props:
30+
31+
- `children` - Content to render inside the link.
32+
- `disabled` - Whether interaction with the link is disabled.
33+
- `onPress` - Callback called when the link is pressed. Calling `preventDefault` on the event prevents navigation.
34+
- `target` - Target for the anchor on the Web, such as `_blank` or `_self`.
35+
- `className` - CSS class for the anchor on the Web.
36+
- `style` - Plain style object for the link. If you need to pass a style array, use `StyleSheet.flatten` to convert it to a plain style object.
37+
- `id` - ID for the rendered element.
38+
- `testID` - ID to locate the link in tests.
39+
- `numberOfLines` - Maximum number of lines for the text on native platforms. This prop has no effect on the Web.
40+
- `aria-label`, `aria-busy`, `aria-expanded`, `aria-hidden`, `aria-labelledby`, `aria-live` - Accessibility properties supported by the link.

versioned_docs/version-8.x/navigation-container.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ See the [Navigation ref](navigation-ref.md) guide for more details.
180180

181181
### Methods on the ref
182182

183-
The ref object includes all of the common navigation methods such as `navigate`, `goBack` etc. See [docs for `CommonActions`](navigation-actions.md) for more details.
183+
The ref object includes common navigation methods such as `navigate`, `goBack` etc. See [docs for `CommonActions`](navigation-actions.md) for more details.
184184

185185
Example:
186186

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

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,15 @@ String that can be used as a fallback for `headerTitle`.
172172

173173
#### `cardShadowEnabled`
174174

175-
Use this prop to have visible shadows during transitions. Defaults to `true`.
175+
Whether to show a shadow during transitions. By default, the shadow is shown when the selected `cardStyleInterpolator` provides a `shadowStyle`.
176+
177+
Set it to `true` to always render the shadow or `false` to disable the shadow.
176178

177179
#### `cardOverlayEnabled`
178180

179-
Use this prop to have a semi-transparent dark overlay visible under the card during transitions. Defaults to `true` on Android and `false` on iOS.
181+
Whether to show a semi-transparent dark overlay under the card during transitions. By default, the overlay is shown when the selected `cardStyleInterpolator` provides an `overlayStyle`.
182+
183+
Set it to `true` to always render the overlay or `false` to disable the overlay.
180184

181185
#### `cardOverlay`
182186

@@ -219,7 +223,7 @@ When `pop` is used, the `pop` animation is applied to the screen being replaced.
219223

220224
#### `gestureEnabled`
221225

222-
Whether you can use gestures to dismiss this screen. Defaults to `true` on iOS, `false` on Android.
226+
Whether you can use gestures to dismiss this screen. It defaults to `true` on iOS for navigation-style transitions that support interactive dismissal, and `false` otherwise.
223227

224228
Gestures are not supported on Web.
225229

@@ -279,7 +283,8 @@ This accepts a function that returns a React Element to display as a header. The
279283
- `navigation` - The navigation object for the current screen.
280284
- `route` - The route object for the current screen.
281285
- `options` - The options for the current screen
282-
- `progress` Animated nodes representing the progress of the animation.
286+
- `progress` - Animated nodes representing the progress of the animation.
287+
- `inverted` - Direction multiplier for the transition. `-1` when inverted, `1` otherwise.
283288
- `back` - Options for the back button, contains an object with a `title` property to use for back button label.
284289
- `styleInterpolator` - Function which returns interpolated styles for various elements in the header.
285290

@@ -628,9 +633,10 @@ This hook returns values related to the screen's animation. It contains the foll
628633

629634
- `current` - Values for the current screen:
630635
- `progress` - Animated node representing the progress value of the current screen.
636+
- `closing` - Animated node representing whether the current screen is using the closing or opening animation. `1` when closing, `0` when opening.
631637
- `next` - Values for the screen after this one in the stack. This can be `undefined` in case the screen animating is the last one.
632638
- `progress` - Animated node representing the progress value of the next screen.
633-
- `closing` - Animated node representing whether the card is closing. `1` when closing, `0` if not.
639+
- `closing` - Animated node representing whether the next screen is using the closing or opening animation. `1` when closing, `0` when opening.
634640
- `swiping` - Animated node representing whether the card is being swiped. `1` when swiping, `0` if not.
635641
- `inverted` - Animated node representing whether the card is inverted. `-1` when inverted, `1` if not.
636642
- `index` - The index of the card in the stack.
@@ -684,6 +690,10 @@ Supported values for `animation` are:
684690

685691
Standard Android-style fade-in from the right for Android 14.
686692

693+
- `flip`
694+
695+
Standard iOS-style horizontal flip.
696+
687697
- <video playsInline autoPlay muted loop>
688698
<source src="/assets/navigators/stack/animation-reveal-from-bottom.mp4" />
689699
</video>
@@ -700,6 +710,14 @@ Supported values for `animation` are:
700710

701711
Scale animation from the center.
702712

713+
- `ios_from_right`
714+
715+
Standard iOS-style slide in from the right.
716+
717+
- `ios_from_left`
718+
719+
Standard iOS-style slide in from the left.
720+
703721
- <video playsInline autoPlay muted loop>
704722
<source src="/assets/navigators/stack/animation-slide-from-right.mp4" />
705723
</video>
@@ -722,7 +740,7 @@ Supported values for `animation` are:
722740

723741
`slide_from_bottom`
724742

725-
Slide animation from the bottom for modals and bottom sheets.
743+
Standard iOS-style slide in from the bottom for modals.
726744

727745
- <video playsInline autoPlay muted loop>
728746
<source src="/assets/navigators/stack/animation-none.mp4" />
@@ -857,12 +875,16 @@ Stack Navigator exposes various options to configure the transition animation wh
857875
The function receives the following properties in its argument:
858876
- `current` - Values for the current screen:
859877
- `progress` - Animated node representing the progress value of the current screen.
878+
- `closing` - Animated node representing whether the current screen is using the closing or opening animation. `1` when closing, `0` when opening.
860879
- `next` - Values for the screen after this one in the stack. This can be `undefined` in case the screen animating is the last one.
861880
- `progress` - Animated node representing the progress value of the next screen.
881+
- `closing` - Animated node representing whether the next screen is using the closing or opening animation. `1` when closing, `0` when opening.
862882
- `index` - The index of the card in the stack.
863-
- `closing` - Animated node representing whether the card is closing. `1` when closing, `0` if not.
883+
- `swiping` - Animated node representing whether the card is being swiped. `1` when swiping, `0` otherwise.
884+
- `inverted` - Animated node representing the transition direction. `-1` when inverted, `1` otherwise.
864885
- `layouts` - Layout measurements for various items we use for animation.
865886
- `screen` - Layout of the whole screen. Contains `height` and `width` properties.
887+
- `insets` - Safe area insets. Contains `top`, `right`, `bottom`, and `left` properties.
866888

867889
> **Note that when a screen is not the last, it will use the next screen's transition config.** This is because many transitions involve an animation of the previous screen, and so these two transitions need to be kept together to prevent running two different kinds of transitions on the two screens (for example a slide and a modal). You can check the `next` parameter to find out if you want to animate out the previous screen. For more information about this parameter, see [Animation](stack-navigator.md#animations) section.
868890
@@ -1020,6 +1042,7 @@ const forSlide = ({ current, next, inverted, layouts: { screen } }) => {
10201042
- `progress` - Animated node representing the progress value of the current screen. `0` when screen should start coming into view, `0.5` when it's mid-way, `1` when it should be fully in view.
10211043
- `next` - Values for the screen after this one in the stack. This can be `undefined` in case the screen animating is the last one.
10221044
- `progress` - Animated node representing the progress value of the next screen.
1045+
- `inverted` - Direction multiplier for the transition. `-1` when inverted, `1` otherwise.
10231046
- `layouts` - Layout measurements for the screen. Each layout object contain `height` and `width` properties.
10241047
- `screen` - Layout of the whole screen.
10251048

@@ -1126,9 +1149,16 @@ With these options, it's possible to build custom transition animations for scre
11261149
#### `TransitionSpecs`
11271150

11281151
- `TransitionIOSSpec` - Exact values from UINavigationController's animation configuration.
1152+
- `FlipIOSSpec` - Configuration for the iOS horizontal flip transition.
11291153
- `FadeInFromBottomAndroidSpec` - Configuration for activity open animation from Android Nougat.
11301154
- `FadeOutToBottomAndroidSpec` - Configuration for activity close animation from Android Nougat.
1131-
- `RevealFromBottomAndroidSpec` - Approximate configuration for activity open animation from Android Pie.
1155+
- `DialogAndroidSpec` - Configuration for the standard Android dialog transition.
1156+
- `RevealFromBottomAndroidSpec` - Configuration for activity open animation from Android Pie.
1157+
- `ScaleFromCenterAndroidSpec` - Configuration for activity open animation from Android 10.
1158+
- `FadeInFromRightAndroidSpec` - Configuration for activity open animation from Android 14 and later.
1159+
- `FadeOutToRightAndroidSpec` - Configuration for activity close animation from Android 14 and later.
1160+
- `BottomSheetSlideInSpec` - Configuration for the Material 3 bottom sheet opening animation.
1161+
- `BottomSheetSlideOutSpec` - Configuration for the Material 3 bottom sheet closing animation.
11321162

11331163
Example:
11341164

@@ -1181,6 +1211,14 @@ import { TransitionSpecs } from '@react-navigation/stack';
11811211
- `forModalPresentationIOS` - Standard iOS-style modal animation.
11821212
- `forFadeFromBottomAndroid` - Standard Android-style fade in from the bottom for Android Oreo.
11831213
- `forRevealFromBottomAndroid` - Standard Android-style reveal from the bottom for Android Pie.
1214+
- `forScaleFromCenterAndroid` - Standard Android-style scale from the center for Android 10.
1215+
- `forFadeFromRightAndroid` - Standard Android-style fade from the right for Android 14 and later.
1216+
- `forBottomSheetAndroid` - Standard Material 3 bottom sheet animation.
1217+
- `forDialogAndroid` - Standard Android dialog animation.
1218+
- `forFadeFromCenter` - Simple fade animation.
1219+
- `forCrossDissolveIOS` - Standard iOS cross-dissolve animation.
1220+
- `forFlipIOS` - Standard iOS horizontal flip animation.
1221+
- `forNoAnimation` - No card animation.
11841222

11851223
Example configuration for Android Oreo style vertical screen fade animation:
11861224

@@ -1249,7 +1287,10 @@ export default function App() {
12491287

12501288
- `forUIKit` - Standard UIKit style animation for the header where the title fades into the back button label.
12511289
- `forFade` - Simple fade animation for the header elements.
1252-
- `forStatic` - Simple translate animation to translate the header along with the sliding screen.
1290+
- `forSlideLeft` - Simple animation that translates the header to the left.
1291+
- `forSlideRight` - Simple animation that translates the header to the right.
1292+
- `forSlideUp` - Simple animation that translates the header up.
1293+
- `forNoAnimation` - No header animation.
12531294

12541295
Example configuration for default iOS animation for header elements where the title fades into the back button:
12551296

@@ -1328,8 +1369,15 @@ We export various transition presets which bundle various set of these options t
13281369
- `ModalSlideFromBottomIOS` - Standard iOS navigation transition for modals.
13291370
- `ModalPresentationIOS` - Standard iOS modal presentation style (introduced in iOS 13).
13301371
- `FadeFromBottomAndroid` - Standard Android navigation transition when opening or closing an Activity on Android < 9 (Oreo).
1372+
- `DialogAndroid` - Standard Android dialog transition.
13311373
- `RevealFromBottomAndroid` - Standard Android navigation transition when opening or closing an Activity on Android 9 (Pie).
13321374
- `ScaleFromCenterAndroid` - Standard Android navigation transition when opening or closing an Activity on Android >= 10.
1375+
- `FadeFromRightAndroid` - Standard Android navigation transition when opening or closing an Activity on Android 14 and later.
1376+
- `BottomSheetAndroid` - Standard Material 3 bottom sheet transition.
1377+
- `ModalFadeTransition` - Fade transition for transparent modals.
1378+
- `ModalFlipIOS` - Standard iOS horizontal flip transition.
1379+
- `CrossDissolveIOS` - Standard iOS cross-dissolve transition.
1380+
- `SlideFromLeftIOS` - Standard iOS navigation transition from the left.
13331381
- `DefaultTransition` - Default navigation transition for the current platform.
13341382
- `ModalTransition` - Default modal transition for the current platform.
13351383

0 commit comments

Comments
 (0)