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
We’ve added a new [`setOptions`](/docs/navigation-prop#setoptions---update-screen-options-from-the-component) method on the `navigation` prop to make configuring screen navigation options more intuitive than its `static navigationOptions` predecessor. It lets us **easily set screen options based on props, state or context without messing with params**. Instead of using static options, we can call it anytime to configure the screen.
59
+
We’ve added a new [`setOptions`](/docs/5.x/navigation-prop#setoptions---update-screen-options-from-the-component) method on the `navigation` prop to make configuring screen navigation options more intuitive than its `static navigationOptions` predecessor. It lets us **easily set screen options based on props, state or context without messing with params**. Instead of using static options, we can call it anytime to configure the screen.
60
60
61
61
```js
62
62
navigation.setOptions({
@@ -77,7 +77,7 @@ It can be used for things like adding a button in the header which needs to inte
77
77
78
78
In React Navigation, we had basic theming support where you could specify whether to use a light or dark theme. It wasn't easy to customize the colors used by the built-in components such as header, tab bar etc. without extra code or repetition.
79
79
80
-
Now, we have revamped the [theme system](/docs/themes) for easier customization. It is possible to provide a theme object with your desired colors for background, accent color etc. and it will automatically change the colors of all navigators without any extra code.
80
+
Now, we have revamped the [theme system](/docs/5.x/themes) for easier customization. It is possible to provide a theme object with your desired colors for background, accent color etc. and it will automatically change the colors of all navigators without any extra code.
81
81
82
82
```js
83
83
constMyTheme= {
@@ -98,7 +98,7 @@ The new version has been written from the ground-up with TypeScript. We now get
98
98
99
99

100
100
101
-
We also have JSDoc for the built-in methods and options, so you get their description directly in your editor. See [our typescript documentation](/docs/typescript) for more details on how to use it.
101
+
We also have JSDoc for the built-in methods and options, so you get their description directly in your editor. See [our typescript documentation](/docs/5.x/typescript) for more details on how to use it.
102
102
103
103
### Redux DevTools integration
104
104
@@ -117,7 +117,7 @@ Traditionally, we have written our navigators in JavaScript for greater customiz
117
117
118
118
### Native backends for Material top tab navigator
119
119
120
-
Similar to native stack, we also have [new backends](/docs/material-top-tab-navigator#pager) for Material top tab navigator based on [`react-native-viewpager`](https://github.com/react-native-community/react-native-viewpager) and [`ScrollView`](https://reactnative.dev/docs/scrollview).
120
+
Similar to native stack, we also have [new backends](/docs/5.x/material-top-tab-navigator#pager) for Material top tab navigator based on [`react-native-viewpager`](https://github.com/react-native-community/react-native-viewpager) and [`ScrollView`](https://reactnative.dev/docs/5.x/scrollview).
@@ -146,9 +146,9 @@ import { ScrollPager } from 'react-native-tab-view';
146
146
In addition to these larger improvements, there are several smaller improvements to fit more use cases and make it easier to do certain tasks:
147
147
148
148
- Revamped drawer navigator to make customizing the drawer sidebar content easier and more flexible.
149
-
- Simpler API for [`reset` action](/docs/navigation-prop#reset) where you can pass the new state directly instead of a chain of actions.
150
-
- More reliable [`focus` and `blur` events](/docs/navigation-lifecycle) to know when a screen's focus state changes.
151
-
- Integration with [`InteractionManager`](https://reactnative.dev/docs/interactionmanager) to delay tasks until animation is complete.
149
+
- Simpler API for [`reset` action](/docs/5.x/navigation-prop#reset) where you can pass the new state directly instead of a chain of actions.
150
+
- More reliable [`focus` and `blur` events](/docs/5.x/navigation-lifecycle) to know when a screen's focus state changes.
151
+
- Integration with [`InteractionManager`](https://reactnative.dev/docs/5.x/interactionmanager) to delay tasks until animation is complete.
152
152
- Better safe area handling with [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context).
153
153
154
154
## Upgrading
@@ -165,7 +165,7 @@ If you were using React Navigation 5 when it was alpha, you might need to check
165
165
166
166
- If you have added `@react-navigation/core` to your dependencies, remove it, and replace all imports from `@react-navigation/core` with `@react-navigation/native`
167
167
- If you were importing `NavigationNativeContainer`, change it to `NavigationContainer`, if you were using `NavigationContainer`, change it to `BaseNavigationContainer`
168
-
- If you had deep linking configured, the config format has changed for nesting. Check the [deep linking docs](/docs/deep-linking) for details.
168
+
- If you had deep linking configured, the config format has changed for nesting. Check the [deep linking docs](/docs/5.x/deep-linking) for details.
Copy file name to clipboardExpand all lines: blog/2021-03-12-react-navigation-6.0-next.md
+8-8
Original file line number
Diff line number
Diff line change
@@ -13,17 +13,17 @@ We're excited to announce that we finally have a prerelease version of React Nav
13
13
14
14
While React Navigation 5 was complete overhaul to the API of React Navigation, React Navigation 6 keeps the same API, with some breaking changes to make things more consistent and provide more flexibility. We also tried to address some common pain points and confusions that users had.
15
15
16
-
We'll share few highlights of the release in this blog post. If you're looking for a detailed upgrade guide, you can find it [here](/docs/upgrading-from-5.x).
16
+
We'll share few highlights of the release in this blog post. If you're looking for a detailed upgrade guide, you can find it [here](/docs/6.x/upgrading-from-5.x).
17
17
18
18
## Highlights
19
19
20
20
- Params are now overwritten on navigation instead of merging (with option to merge them)
21
-
- Modals in [stack](/docs/stack-navigator) now use the presentation style on iOS by default, and there's a new slide animation for modals on Android
22
-
-[Drawer](/docs/drawer-navigator) now uses a slide animation by default on iOS
23
-
- Headers are now shown by default in [drawer](/docs/drawer-navigator) and [bottom tab](/docs/bottom-tab-navigator) screens, so you don't need extra stack navigators
24
-
- We got rid of `tabBarOptions`, `drawerContentOptions` etc. and moved those to [`options` prop on screen](/docs/screen-options) to make it possible to configure them per screen
25
-
-[Material Top Tabs](/docs/material-top-tab-navigator) now use a `ViewPager` based implementation, which means it'll provide a native experience
26
-
- We now have a [UI elements library](/docs/elements) which contains various components we use in React Navigation
21
+
- Modals in [stack](/docs/6.x/stack-navigator) now use the presentation style on iOS by default, and there's a new slide animation for modals on Android
22
+
-[Drawer](/docs/6.x/drawer-navigator) now uses a slide animation by default on iOS
23
+
- Headers are now shown by default in [drawer](/docs/6.x/drawer-navigator) and [bottom tab](/docs/6.x/bottom-tab-navigator) screens, so you don't need extra stack navigators
24
+
- We got rid of `tabBarOptions`, `drawerContentOptions` etc. and moved those to [`options` prop on screen](/docs/6.x/screen-options) to make it possible to configure them per screen
25
+
-[Material Top Tabs](/docs/6.x/material-top-tab-navigator) now use a `ViewPager` based implementation, which means it'll provide a native experience
26
+
- We now have a [UI elements library](/docs/6.x/elements) which contains various components we use in React Navigation
We're planning to update our documentation to recommend [native-stack](/docs/native-stack-navigator) as the default. This will provide the best performance for people who don't need a lot of customization, while still having the option to use the JavaScript based implementation if they need it.
38
+
We're planning to update our documentation to recommend [native-stack](/docs/6.x/native-stack-navigator) as the default. This will provide the best performance for people who don't need a lot of customization, while still having the option to use the JavaScript based implementation if they need it.
The documentation is now live at [reactnavigation.org](https://reactnavigation.org), and v5 lives [here](/docs/5.x/getting-started).
10
+
The documentation is now live at [reactnavigation.org](https://reactnavigation.org/6.x/getting-started), and v5 lives [here](/docs/5.x/getting-started).
11
11
12
12
React Navigation 6 keeps mostly the same core API as React Navigation 5, and you can think of it as further polishing what was in React Navigation 5. Let's talk about the highlights of this release in this blog post.
13
13
@@ -49,27 +49,27 @@ In React Navigation 6, many of these props are now screen options. The most sign
49
49
>
50
50
```
51
51
52
-
See [deprecations](/docs/upgrading-from-5.x#deprecations) for more details.
52
+
See [deprecations](/docs/6.x/upgrading-from-5.x#deprecations) for more details.
53
53
54
54
### Elements library
55
55
56
-
We extracted some of the components and helpers used across various navigators in React Navigation and published them under a new package called [`@react-navigation/elements`](/docs/elements). It can be useful if you're building your own navigator, or just want to reuse some of the components in your app.
56
+
We extracted some of the components and helpers used across various navigators in React Navigation and published them under a new package called [`@react-navigation/elements`](/docs/6.x/elements). It can be useful if you're building your own navigator, or just want to reuse some of the components in your app.
57
57
58
58
Currently only a small set of components are exported, but there are more to come.
59
59
60
60
### Simplified APIs for existing functionality
61
61
62
62
We simplified many APIs with React Navigation 6 to address common use cases. For example:
63
63
64
-
- Single option to use a modal presentation style and transparent modal with [`presentation`](/docs/stack-navigator#presentation)
64
+
- Single option to use a modal presentation style and transparent modal with [`presentation`](/docs/6.x/stack-navigator#presentation)
- The `useHeaderHeight` hook now ignores hidden headers and returns the height of the closest visible header in parent
67
-
- New option to set a [custom background](/docs/bottom-tab-navigator#tabbarbackground) (such as `BlurView`) for tab bar without having to use a custom tab bar
68
-
- New API to manage ref on the container [(`createNavigationContainerRef` and `useNavigationContainerRef`)](/docs/navigating-without-navigation-prop)
67
+
- New option to set a [custom background](/docs/6.x/bottom-tab-navigator#tabbarbackground) (such as `BlurView`) for tab bar without having to use a custom tab bar
68
+
- New API to manage ref on the container [(`createNavigationContainerRef` and `useNavigationContainerRef`)](/docs/6.x/navigating-without-navigation-prop)
69
69
70
70
### New `Group` component for organization
71
71
72
-
The [`Group`](/docs/group) component helps you organize screens inside your navigators and share common `screenOptions` between the `Group`s. Passing `screenOptions` to a group configures all the screens inside that group to use these options. You can override `Group` options by passing `options` to each Screen component, similar to how you can with `screenOptions` on Navigator. You can also nest `Group` components inside other `Group` components. They are lightweight and don’t render anything - like fragments, so they won’t affect performance.
72
+
The [`Group`](/docs/6.x/group) component helps you organize screens inside your navigators and share common `screenOptions` between the `Group`s. Passing `screenOptions` to a group configures all the screens inside that group to use these options. You can override `Group` options by passing `options` to each Screen component, similar to how you can with `screenOptions` on Navigator. You can also nest `Group` components inside other `Group` components. They are lightweight and don’t render anything - like fragments, so they won’t affect performance.
73
73
74
74
In this code snippet, you can see that we group regular screens under one group and modal screens under another group:
75
75
@@ -93,13 +93,13 @@ function App() {
93
93
94
94
Developers often want to show a header for screens inside of drawers and bottom tabs. To do this, we had to nest a stack navigator which provides a header, even if it was a navigator with just one screen. So we now show headers by default in screens of drawer and bottom tabs. No nesting necessary.
95
95
96
-
We also export a [`Header`](/docs/elements#header) component in the new elements library to use anywhere in your components.
96
+
We also export a [`Header`](/docs/6.x/elements#header) component in the new elements library to use anywhere in your components.
97
97
98
98
### Native navigation by default
99
99
100
100
Historically, React Navigation has been mostly JS based, with animations and gestures written in JavaScript on top of `react-native-gesture-handler`, and `react-native-reanimated` or `Animated`. While this works for a lot of apps, apps with heavy screens can suffer from poor performance, and some native features are difficult to re-create exactly (such as the large header on iOS). So, we wanted to address this by using native primitives for navigation.
101
101
102
-
With React Navigation 5, we introduced [`@react-navigation/native-stack`](/docs/native-stack-navigator) package powered by [`react-native-screens`](https://github.com/software-mansion/react-native-screens), as well as a native backend for [`@react-navigation/material-top-tabs`](/docs/material-top-tab-navigator) powered by [`react-native-pager-view`](https://github.com/callstack/react-native-pager-view).
102
+
With React Navigation 5, we introduced [`@react-navigation/native-stack`](/docs/6.x/native-stack-navigator) package powered by [`react-native-screens`](https://github.com/software-mansion/react-native-screens), as well as a native backend for [`@react-navigation/material-top-tabs`](/docs/6.x/material-top-tab-navigator) powered by [`react-native-pager-view`](https://github.com/callstack/react-native-pager-view).
103
103
104
104
In React Navigation 6, we made `@react-navigation/native-stack` the default choice for setting up Stack navigation. It uses `UINavigationController` on iOS and Fragments on Android to implement navigation natively. We also focused a lot on aligning the API of `@react-navigation/native-stack` with `@react-navigation/stack` so that it’ll be easier to switch between them.
105
105
@@ -125,7 +125,7 @@ declare global {
125
125
}
126
126
```
127
127
128
-
You can read [more about it in our TypeScript docs](/docs/typescript#specifying-default-types-for-usenavigation-link-ref-etc).
128
+
You can read [more about it in our TypeScript docs](/docs/6.x/typescript#specifying-default-types-for-usenavigation-link-ref-etc).
129
129
130
130
### Flipper plugin
131
131
@@ -139,13 +139,13 @@ One advantage of the Flipper plugin over Redux Devtools Extension is that it doe
See the [guide for setting it up](/docs/devtools#useflipper) for more details. Note that Flipper support in Expo managed apps requires a [Custom Development Client](https://docs.expo.dev/clients/introduction/) and it does not work in Expo Go at the time of writing.
142
+
See the [guide for setting it up](/docs/6.x/devtools#useflipper) for more details. Note that Flipper support in Expo managed apps requires a [Custom Development Client](https://docs.expo.dev/clients/introduction/) and it does not work in Expo Go at the time of writing.
143
143
144
144
## Upgrading
145
145
146
146
While React Navigation 6 doesn't introduce changes of the same magnitude as React Navigation 5, there are still some breaking changes. It is possible, however, to mix packages from React Navigation 5 and React Navigation 6 (with a few caveats) so that you can gradually upgrade packages.
147
147
148
-
See the [upgrade guide](/docs/upgrading-from-5.x) for a full list of changes and more details.
148
+
See the [upgrade guide](/docs/6.x/upgrading-from-5.x) for a full list of changes and more details.
Copy file name to clipboardExpand all lines: blog/2024-03-25-introducing-static-api.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -67,7 +67,7 @@ function App() {
67
67
68
68
This component is similar to `NavigationContainer` and accepts most of the props accepted by `NavigationContainer`. So this is the place where you can do things like track for screen changes, persist navigation state etc.
69
69
70
-
See [Static API reference](/docs/7.x/static-configuration?config=static) for more details.
70
+
See [Static API reference](/docs/static-configuration?config=static) for more details.
71
71
72
72
## TypeScript
73
73
@@ -84,7 +84,7 @@ declare global {
84
84
}
85
85
```
86
86
87
-
See [Type checking with TypeScript](/docs/7.x/typescript?config=static) for more details.
87
+
See [Type checking with TypeScript](/docs/typescript?config=static) for more details.
88
88
89
89
## Deep Linking
90
90
@@ -152,7 +152,7 @@ There are 2 improvements to deep linking API:
152
152
}
153
153
```
154
154
155
-
See [Configuring links](/docs/7.x/configuring-links?config=static) for more details.
155
+
See [Configuring links](/docs/configuring-links?config=static) for more details.
The if property takes a hook that returns a boolean. When the hook returns true, the screen will be included in the navigation tree, and when it returns false, it won’t be included.
177
177
178
-
See [Authentication flows](/docs/7.x/auth-flow?config=static) for more details.
178
+
See [Authentication flows](/docs/auth-flow?config=static) for more details.
179
179
180
180
## Interoperability
181
181
182
182
Since we have 2 different APIs in the same library, it's important that they both work together. This way you could start an app with the static API, but if you need flexibility for a specific navigator, you could use the dynamic API for that part. Or you may want to migrate to the static API to reduce the complexity, and with the interoperability, you can do that incrementally.
183
183
184
-
See [Combining static and dynamic APIs](/docs/7.x/combine-static-with-dynamic) for more details.
184
+
See [Combining static and dynamic APIs](/docs/combine-static-with-dynamic) for more details.
185
185
186
186
## Help us test
187
187
@@ -191,6 +191,6 @@ The Static API is currently available in React Navigation 7 alpha. You can try i
In addition to the static API, React Navigation 7 also includes a lot of other improvements and new features. Make sure to go through the [upgrade guide](/docs/7.x/upgrading-from-6.x) to see all the changes.
194
+
In addition to the static API, React Navigation 7 also includes a lot of other improvements and new features. Make sure to go through the [upgrade guide](/docs/upgrading-from-6.x) to see all the changes.
195
195
196
196
We would love to get feedback from the community on how it works for you and catch any issues before the stable release. If you have any feedback or suggestions, please let us know on our [GitHub Discussions forum](https://github.com/react-navigation/react-navigation/discussions). If you find any issues, please report them on our [GitHub issues](https://github.com/react-navigation/react-navigation/issues).
0 commit comments