Skip to content

Commit 84ced9c

Browse files
authored
Merge branch 'main' into patch-1
2 parents 1114ca9 + 193da95 commit 84ced9c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4315
-4105
lines changed

blog/2020-02-06-react-navigation-5.0.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ Hooks are great for stateful logic and code organization. Now we have several ho
5252
- [`useNavigationState`](/docs/use-navigation-state)
5353
- [`useFocusEffect`](/docs/use-focus-effect)
5454
- [`useIsFocused`](/docs/use-is-focused)
55-
- [`useLinking`](/docs/use-linking)
5655
- [`useScrollToTop`](/docs/use-scroll-to-top)
5756

5857
### Update options from component
@@ -158,7 +157,7 @@ This is a big release and, while the basic concepts such as nesting are the same
158157

159158
We recommend starting your new projects with the new version so you can take advantage of the new APIs and the new features.
160159

161-
We have written an [upgrade guide](/docs/upgrading-from-4.x) which will give you an overview of what's changed and how to adapt the old API and concepts to the new API.
160+
We have written an [upgrade guide](/docs/5.x/upgrading-from-4.x) which will give you an overview of what's changed and how to adapt the old API and concepts to the new API.
162161

163162
## A note for alpha users
164163

blog/2020-05-16-web-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ It's especially important in case of the [stack navigator](/docs/stack-navigator
101101
102102
### Permanent drawer
103103
104-
Another way we can make maximum us of the available screen size is by making our UIs adapt to different screen sizes. For example, we may want to show a sidebar for navigation on large screens while switching to a drawer on smaller screens. You can now specify `drawerType` as `permanent` to show an always visible sidebar. See the [documentation for `drawerType`](/docs/drawer-navigator#drawertype) for example code on how to achieve it.
104+
Another way we can make maximum use of the available screen size is by making our UIs adapt to different screen sizes. For example, we may want to show a sidebar for navigation on large screens while switching to a drawer on smaller screens. You can now specify `drawerType` as `permanent` to show an always visible sidebar. See the [documentation for `drawerType`](/docs/drawer-navigator#drawertype) for example code on how to achieve it.
105105
106106
<video playsInline autoPlay muted loop style={{ maxWidth: '100%' }}>
107107
<source src="/assets/blog/web-support/permanent-drawer.mp4" type="video/mp4" />

blog/2021-03-12-react-navigation-6.0-next.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@ We're excited to announce that we finally have a prerelease version of React Na
1313

1414
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.
1515

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).
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).
1717

1818
## Highlights
1919

2020
- Params are now overwritten on navigation instead of merging (with option to merge them)
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
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
2727

2828
## Try it out
2929

30-
The new versions are published under `next` tag on [npm](https://npmjs.org). So if you'd like to try it out, add `@next` to the package, you're installing. For example:
30+
If you'd like to try it out, add `@^6.x` to the package, you're installing. For example:
3131

3232
```sh npm2yarn
33-
npm install @react-navigation/native@next @react-navigation/stack@next
33+
npm install @react-navigation/native@^6.x @react-navigation/stack@^6.x
3434
```
3535

3636
## What's next?
3737

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.
38+
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.
3939

4040
## Sponsor us
4141

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
---
2+
title: React Navigation 6.0
3+
author: Satyajit Sahoo
4+
author_url: https://twitter.com/satya164
5+
author_title: Core Team
6+
author_image_url: https://avatars2.githubusercontent.com/u/1174278?s=200&v=4
7+
tags: [release, announcement]
8+
---
9+
10+
The documentation is now live at [reactnavigation.org](https://reactnavigation.org), and v5 lives [here](/docs/5.x/getting-started).
11+
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+
14+
<!--truncate-->
15+
16+
## Highlights
17+
18+
### More flexible navigators
19+
20+
Navigators accept many of their customization options as props, which means we can’t customize them based on the active screen. To make this level of control possible, we needed to move these props to options that you can configure per screen.
21+
22+
In React Navigation 6, many of these props are now screen options. The most significant changes are `tabBarOptions` and `drawerContentOptions`, which now all live on `options` instead. For example:
23+
24+
```js
25+
// Before (v5)
26+
<Tab.Navigator
27+
tabBarOptions={{
28+
inactiveTintColor: 'rgba(255, 255, 255, 0.5)',
29+
activeTintColor: '#fff',
30+
style: {
31+
position: 'absolute',
32+
borderTopColor: 'rgba(0, 0, 0, .2)',
33+
},
34+
}}
35+
>
36+
```
37+
38+
```js
39+
// After (v6)
40+
<Tab.Navigator
41+
screenOptions={{
42+
tabBarInactiveTintColor: 'rgba(255, 255, 255, 0.5)',
43+
tabBarActiveTintColor: '#fff',
44+
tabBarStyle: {
45+
position: 'absolute',
46+
borderTopColor: 'rgba(0, 0, 0, .2)',
47+
},
48+
}}
49+
>
50+
```
51+
52+
See [deprecations](/docs/upgrading-from-5.x#deprecations) for more details.
53+
54+
### Elements library
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.
57+
58+
Currently only a small set of components are exported, but there are more to come.
59+
60+
### Simplified APIs for existing functionality
61+
62+
We simplified many APIs with React Navigation 6 to address common use cases. For example:
63+
64+
- Single option to use a modal presentation style and transparent modal with [`presentation`](/docs/stack-navigator#presentation)
65+
- Custom header doesn't require setting `headerMode="screen"` manually anymore
66+
- 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)
69+
70+
### New `Group` component for organization
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.
73+
74+
In this code snippet, you can see that we group regular screens under one group and modal screens under another group:
75+
76+
```js
77+
function App() {
78+
return (
79+
<Stack.Navigator>
80+
<Stack.Group>
81+
<Stack.Screen name="Home" component={HomeScreen} />
82+
<Stack.Screen name="Details" component={DetailsScreen} />
83+
</Stack.Group>
84+
<Stack.Group screenOptions={{ presentation: 'modal' }}>
85+
<Stack.Screen
86+
name="CreatePost"
87+
component={CreatePostScreen}
88+
/>
89+
</Stack.Group>
90+
</Stack.Navigator>
91+
);
92+
}
93+
```
94+
95+
### Headers by default in Bottom Tabs & Drawer
96+
97+
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.
98+
99+
We also export a [`Header`](/docs/elements#header) component in the new elements library to use anywhere in your components.
100+
101+
### Native navigation by default
102+
103+
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.
104+
105+
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).
106+
107+
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.
108+
109+
> While `@react-navigation/native-stack` is now used as the default choice in the documentation, it doesn't replace `@react-navigation/stack`. Both packages are maintained and are valid options for your projects. If you're currently using `@react-navigation/stack`, you can keep using it. You don't need to move to `@react-navigation/native-stack` unless you really want to.
110+
111+
Similarly, we switched `@react-navigation/material-top-tabs` to use `react-native-pager-view` by default.
112+
113+
### Better type-safety
114+
115+
React Navigation 5’s TypeScript support was much better than React Navigation 4; but, some things such as `useNavigation` were still untyped by default.
116+
117+
In React Navigation 6, you don’t need to annotate `useNavigation` to get autocompletion and type checking. This is possible by defining a type for the screens globally using declaration merging:
118+
119+
```js
120+
declare global {
121+
namespace ReactNavigation {
122+
interface RootParamList {
123+
Home: undefined;
124+
Profile: { userId: string };
125+
NotFound: undefined;
126+
}
127+
}
128+
}
129+
```
130+
131+
You can read [more about it in our TypeScript docs](/docs/typescript#specifying-default-types-for-usenavigation-link-ref-etc).
132+
133+
### Flipper plugin
134+
135+
Our new [Flipper](https://fbflipper.com/) plugin includes similar functionality to the currently available Redux Devtools Extensions integration. You can see all navigation actions, and jump back and forth between earlier and new navigation states. In addition, it also includes a tab to test your linking configuration.
136+
137+
Since the dev tools is built from scratch, we’re now free to add new features to make debugging easier in future.
138+
139+
One advantage of the Flipper plugin over Redux Devtools Extension is that it doesn’t need Chrome Debugger to work. Since Chrome Debugger can sometimes affect performance and even potentially change behavior, we think this is a more reliable solution.
140+
141+
![React Navigation Logs](/assets/devtools/flipper-plugin-logs.png)
142+
143+
![React Navigation Linking](/assets/devtools/flipper-plugin-linking.png)
144+
145+
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.
146+
147+
## Upgrading
148+
149+
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.
150+
151+
See the [upgrade guide](/docs/upgrading-from-5.x) for a full list of changes and more details.
152+
153+
## Sponsor us
154+
155+
If React Navigation helps you to deliver value to your customers, it'd awesome a lot if you could sponsor us. Sponsorships will help us to move more quickly towards our goal of building the best cross-platform navigation library and continue to provide timely support for bug reports in our GitHub issues.
156+
157+
👉 [Visit our GitHub Sponsors page](https://github.com/sponsors/react-navigation) 👈

docusaurus.config.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = {
1414
'/js/code-block-buttons.js',
1515
],
1616
themeConfig: {
17-
sidebarCollapsible: false,
1817
googleAnalytics: {
1918
trackingID: 'UA-10128745-16',
2019
},
@@ -95,7 +94,7 @@ module.exports = {
9594
href: 'https://react-navigation.canny.io/feature-requests',
9695
},
9796
{
98-
label: 'Report a bug on Github',
97+
label: 'Report a bug on GitHub',
9998
href:
10099
'https://github.com/react-navigation/react-navigation/issues/new/choose',
101100
},
@@ -152,13 +151,9 @@ module.exports = {
152151
'https://github.com/react-navigation/react-navigation.github.io/edit/main/',
153152
remarkPlugins: [require('./src/plugins/remark-npm2yarn')],
154153
includeCurrentVersion: false,
155-
lastVersion: '5.x',
156-
versions: {
157-
'6.x': {
158-
label: '6.x (next)',
159-
},
160-
},
154+
lastVersion: '6.x'
161155
},
156+
sidebarCollapsible: false,
162157
theme: {
163158
customCss: require.resolve('./src/css/custom.css'),
164159
},

package.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,29 @@
55
"scripts": {
66
"start": "docusaurus start",
77
"build": "docusaurus build",
8+
"clear": "docusaurus clear",
9+
"serve": "docusaurus serve",
810
"swizzle": "docusaurus swizzle",
9-
"deploy": "docusaurus deploy",
11+
"deploy": "DEPLOYMENT_BRANCH=gh-pages docusaurus deploy",
1012
"crowdin-upload": "crowdin upload sources --auto-update -b main",
1113
"crowdin-download": "crowdin download -b main",
1214
"fetch-sponsors": "node scripts/fetch-sponsors.js"
1315
},
1416
"dependencies": {
15-
"@docusaurus/core": "2.0.0-alpha.75",
16-
"@docusaurus/plugin-google-analytics": "2.0.0-alpha.75",
17-
"@docusaurus/preset-classic": "2.0.0-alpha.75",
18-
"@octokit/graphql": "^4.5.7",
19-
"@react-navigation/core": "^5.14.3",
20-
"classnames": "^2.2.6",
17+
"@docusaurus/core": "2.0.0-beta.7",
18+
"@docusaurus/plugin-google-analytics": "2.0.0-beta.7",
19+
"@docusaurus/preset-classic": "2.0.0-beta.7",
20+
"@docusaurus/remark-plugin-npm2yarn": "2.0.0-beta.7",
21+
"@octokit/graphql": "^4.8.0",
22+
"@react-navigation/core": "^6.0.1",
23+
"classnames": "^2.3.1",
2124
"docsearch.js": "^2.6.3",
2225
"escape-html": "^1.0.3",
2326
"mkdirp": "^1.0.4",
2427
"netlify-plugin-cache": "^1.0.3",
2528
"prism-react-renderer": "^1.1.1",
26-
"react": "^17.0.1",
27-
"react-dom": "^17.0.1",
29+
"react": "^17.0.2",
30+
"react-dom": "^17.0.2",
2831
"react-simple-code-editor": "^0.11.0"
2932
},
3033
"browserslist": {

src/SnackHelpers.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ const DEPS_VERSIONS = {
1515
'5': [
1616
'@expo/vector-icons@*',
1717
'@react-native-community/masked-view@*',
18-
"@react-navigation/bottom-tabs@^5.8.0",
19-
"@react-navigation/drawer@^5.9.0",
20-
"@react-navigation/material-bottom-tabs@^5.2.16",
21-
"@react-navigation/material-top-tabs@^5.2.16",
22-
"@react-navigation/native@^5.7.3",
23-
"@react-navigation/stack@^5.9.0",
18+
"@react-navigation/bottom-tabs@^5.11.15",
19+
"@react-navigation/drawer@^5.12.9",
20+
"@react-navigation/material-bottom-tabs@^5.3.19",
21+
"@react-navigation/material-top-tabs@^5.3.19",
22+
"@react-navigation/native@^5.9.8",
23+
"@react-navigation/stack@^5.14.9",
2424
'react-native-paper@^4.0.1',
2525
'react-native-reanimated@*',
2626
'react-native-safe-area-context@*',
@@ -38,14 +38,14 @@ const DEPS_VERSIONS = {
3838
'react-native-safe-area-context@*',
3939
'react-native-screens@*',
4040
'react-native-tab-view@^3.0.0',
41-
'@react-navigation/bottom-tabs@6.0.0-next.12',
42-
'@react-navigation/drawer@6.0.0-next.11',
43-
'@react-navigation/elements@1.0.0-next.11',
44-
'@react-navigation/material-bottom-tabs@6.0.0-next.9',
45-
'@react-navigation/material-top-tabs@6.0.0-next.10',
46-
'@react-navigation/native-stack@6.0.0-next.1',
47-
'@react-navigation/native@6.0.0-next.9',
48-
'@react-navigation/stack@6.0.0-next.19',
41+
'@react-navigation/bottom-tabs@6.0.4',
42+
'@react-navigation/drawer@6.1.3',
43+
'@react-navigation/elements@1.0.4',
44+
'@react-navigation/material-bottom-tabs@6.0.4',
45+
'@react-navigation/material-top-tabs@6.0.2',
46+
'@react-navigation/native-stack@6.0.5',
47+
'@react-navigation/native@6.0.2',
48+
'@react-navigation/stack@6.0.6',
4949
],
5050
next: [],
5151
};

src/data/sponsors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export default [
9595
"name": "Alexi Canales"
9696
},
9797
{
98-
"avatarUrl": "https://avatars.githubusercontent.com/u/21980965?u=418759528b6cd702bc1204278ea87b97f32f5e3c&v=4",
98+
"avatarUrl": "https://avatars.githubusercontent.com/u/21980965?u=5a571092a83cb71508c60a9c86ab2520fde8a68e&v=4",
9999
"username": "jarvisluong",
100100
"name": "Jarvis Luong"
101101
},

src/pages/home/Splash/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default function Splash() {
4343
<div className={styles.migrationText}>
4444
💡 Coming from v4? Check out our{' '}
4545
<Link
46-
to={useBaseUrl('/docs/upgrading-from-4.x')}
46+
to={useBaseUrl('/docs/5.x/upgrading-from-4.x')}
4747
className={styles.linkText}
4848
>
4949
v4 to v5 migration guide

src/pages/layouts/DocPage.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@ function DocPage(props) {
1818
});
1919

2020
React.useEffect(() => {
21+
2122
initializeSnackObservers();
23+
//note: @eriveltonelias
24+
// currently on docusaurus v2.0.0-beta.7 when the page loads on the first time
25+
// the anchor links is not working as expected.
26+
const hashId = window.location.hash;
27+
const element = document.getElementById(hashId.split('#').join(''));
28+
if (element) {
29+
element.scrollIntoView();
30+
}
2231

2332
return () => {
2433
removeSnackObservers();

0 commit comments

Comments
 (0)