Skip to content

Commit 2d41d39

Browse files
committed
Merge branch 'main' into @eds2002/screen-transitions-blog
2 parents a72d0ee + 57cf63e commit 2d41d39

34 files changed

Lines changed: 872 additions & 612 deletions

src/__tests__/process-markdown.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ describe('processMarkdown', () => {
146146

147147
const { content: result } = await processMarkdown(input);
148148

149-
assert.ok(result.includes('**Static:**'));
149+
assert.ok(result.includes('**Static (Recommended):**'));
150150
assert.ok(result.includes('**Dynamic:**'));
151151
assert.ok(result.includes('NavigationContainer'));
152152
assert.ok(!result.includes('static2dynamic'));

src/plugins/process-markdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ async function transformStatic2Dynamic(content: string): Promise<string> {
293293
const langTag = m.lang || 'js';
294294
const metaSuffix = cleanMeta ? ` ${cleanMeta}` : '';
295295

296-
const staticSection = `**Static:**\n\n\`\`\`${langTag}${metaSuffix}\n${m.code}\`\`\``;
296+
const staticSection = `**Static (Recommended):**\n\n\`\`\`${langTag}${metaSuffix}\n${m.code}\`\`\``;
297297
const dynamicSection = `**Dynamic:**\n\n\`\`\`${langTag}${metaSuffix}\n${dynamicCode}\n\`\`\``;
298298

299299
return {

versioned_docs/version-7.x/bottom-tab-navigator.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,8 @@ export default function App() {
752752
}
753753
```
754754
755+
See [`jumpTo`](tab-actions.md#jumpto) for more details.
756+
755757
### Hooks
756758
757759
The bottom tab navigator exports the following hooks:

versioned_docs/version-7.x/deep-linking.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This guide will describe how to configure your app to handle deep links on vario
1414

1515
React Native provides a [`Linking`](https://reactnative.dev/docs/linking) to get notified of incoming links. React Navigation can integrate with the `Linking` module to automatically handle deep links. On Web, React Navigation can integrate with browser's `history` API to handle URLs on client side. See [configuring links](configuring-links.md) to see more details on how to configure links in React Navigation.
1616

17-
While you don't need to use the `linking` prop from React Navigation, and can handle deep links yourself by using the `Linking` API and navigating from there, it'll be significantly more complicated than using the `linking` prop which handles many edge cases for you. So we don't recommend implementing it by yourself.
17+
We don't recommend handling deep links yourself using a [`ref`](navigation-container.md#ref) as it can be error-prone and significantly more complicated. Using the `linking` prop is the recommended way to handle deep links in React Navigation.
1818

1919
Below, we'll go through required configurations so that the deep link integration works.
2020

versioned_docs/version-7.x/drawer-actions.md

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import TabItem from '@theme/TabItem';
99

1010
`DrawerActions` is an object containing methods for generating actions specific to drawer-based navigators. Its methods expand upon the actions available in [CommonActions](navigation-actions.md).
1111

12+
For screens inside a [Drawer Navigator](drawer-navigator.md), drawer actions are available as methods on the `navigation` object.
13+
1214
The following actions are supported:
1315

1416
## openDrawer
@@ -34,7 +36,7 @@ function HomeScreen() {
3436
<Button
3537
onPress={() => {
3638
// codeblock-focus-start
37-
navigation.dispatch(DrawerActions.openDrawer());
39+
navigation.openDrawer();
3840
// codeblock-focus-end
3941
}}
4042
>
@@ -57,6 +59,14 @@ export default function App() {
5759
}
5860
```
5961

62+
It can also be used with `navigation.dispatch`:
63+
64+
```js
65+
import { DrawerActions } from '@react-navigation/native';
66+
67+
navigation.dispatch(DrawerActions.openDrawer());
68+
```
69+
6070
## closeDrawer
6171

6272
The `closeDrawer` action can be used to close the drawer pane.
@@ -68,7 +78,6 @@ import { Button } from '@react-navigation/elements';
6878
import {
6979
createStaticNavigation,
7080
useNavigation,
71-
DrawerActions,
7281
} from '@react-navigation/native';
7382
import {
7483
createDrawerNavigator,
@@ -83,9 +92,7 @@ function HomeScreen() {
8392
return (
8493
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
8594
<Text>Home!</Text>
86-
<Button onPress={() => navigation.dispatch(DrawerActions.openDrawer())}>
87-
Open Drawer
88-
</Button>
95+
<Button onPress={() => navigation.openDrawer()}>Open Drawer</Button>
8996
</View>
9097
);
9198
}
@@ -100,7 +107,7 @@ function CustomDrawerContent(props) {
100107
label="Close drawer"
101108
onPress={() => {
102109
// codeblock-focus-start
103-
navigation.dispatch(DrawerActions.closeDrawer());
110+
navigation.closeDrawer();
104111
// codeblock-focus-end
105112
}}
106113
/>
@@ -122,6 +129,14 @@ export default function App() {
122129
}
123130
```
124131

132+
It can also be used with `navigation.dispatch`:
133+
134+
```js
135+
import { DrawerActions } from '@react-navigation/native';
136+
137+
navigation.dispatch(DrawerActions.closeDrawer());
138+
```
139+
125140
## toggleDrawer
126141

127142
The `toggleDrawer` action can be used to toggle the drawer pane.
@@ -133,48 +148,29 @@ import { Button } from '@react-navigation/elements';
133148
import {
134149
createStaticNavigation,
135150
useNavigation,
136-
DrawerActions,
137151
} from '@react-navigation/native';
138-
import {
139-
createDrawerNavigator,
140-
DrawerContentScrollView,
141-
DrawerItemList,
142-
DrawerItem,
143-
} from '@react-navigation/drawer';
152+
import { createDrawerNavigator } from '@react-navigation/drawer';
144153

145154
function HomeScreen() {
146155
const navigation = useNavigation();
147156

148157
return (
149158
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
150159
<Text>Home!</Text>
151-
<Button onPress={() => navigation.dispatch(DrawerActions.toggleDrawer())}>
152-
Toggle Drawer
153-
</Button>
154-
</View>
155-
);
156-
}
157-
158-
function CustomDrawerContent(props) {
159-
const { navigation } = props;
160-
161-
return (
162-
<DrawerContentScrollView {...props}>
163-
<DrawerItemList {...props} />
164-
<DrawerItem
165-
label="Toggle drawer"
160+
<Button
166161
onPress={() => {
167162
// codeblock-focus-start
168-
navigation.dispatch(DrawerActions.toggleDrawer());
163+
navigation.toggleDrawer();
169164
// codeblock-focus-end
170165
}}
171-
/>
172-
</DrawerContentScrollView>
166+
>
167+
Toggle Drawer
168+
</Button>
169+
</View>
173170
);
174171
}
175172

176173
const MyDrawer = createDrawerNavigator({
177-
drawerContent: (props) => <CustomDrawerContent {...props} />,
178174
screens: {
179175
Home: HomeScreen,
180176
},
@@ -187,6 +183,14 @@ export default function App() {
187183
}
188184
```
189185

186+
It can also be used with `navigation.dispatch`:
187+
188+
```js
189+
import { DrawerActions } from '@react-navigation/native';
190+
191+
navigation.dispatch(DrawerActions.toggleDrawer());
192+
```
193+
190194
## jumpTo
191195

192196
The `jumpTo` action can be used to jump to an existing route in the drawer navigator.
@@ -201,7 +205,6 @@ import { Button } from '@react-navigation/elements';
201205
import {
202206
createStaticNavigation,
203207
useNavigation,
204-
DrawerActions,
205208
} from '@react-navigation/native';
206209
import { createDrawerNavigator } from '@react-navigation/drawer';
207210

@@ -214,9 +217,7 @@ function HomeScreen() {
214217
<Button
215218
onPress={() => {
216219
// codeblock-focus-start
217-
navigation.dispatch(
218-
DrawerActions.jumpTo('Profile', { user: 'Satya' })
219-
);
220+
navigation.jumpTo('Profile', { user: 'Satya' });
220221
// codeblock-focus-end
221222
}}
222223
>
@@ -250,3 +251,11 @@ export default function App() {
250251
return <Navigation />;
251252
}
252253
```
254+
255+
It can also be used with `navigation.dispatch`:
256+
257+
```js
258+
import { DrawerActions } from '@react-navigation/native';
259+
260+
navigation.dispatch(DrawerActions.jumpTo('Profile', { user: 'Satya' }));
261+
```

versioned_docs/version-7.x/drawer-navigator.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,8 @@ export default function App() {
749749
}
750750
```
751751

752+
See [`openDrawer`](drawer-actions.md#opendrawer) for more details.
753+
752754
#### `closeDrawer`
753755

754756
Closes the drawer pane.
@@ -757,6 +759,8 @@ Closes the drawer pane.
757759
navigation.closeDrawer();
758760
```
759761

762+
See [`closeDrawer`](drawer-actions.md#closedrawer) for more details.
763+
760764
#### `toggleDrawer`
761765

762766
Opens the drawer pane if closed, closes the drawer pane if opened.
@@ -765,6 +769,8 @@ Opens the drawer pane if closed, closes the drawer pane if opened.
765769
navigation.toggleDrawer();
766770
```
767771

772+
See [`toggleDrawer`](drawer-actions.md#toggledrawer) for more details.
773+
768774
#### `jumpTo`
769775

770776
Navigates to an existing screen in the drawer navigator. The method accepts the following arguments:
@@ -827,6 +833,8 @@ export default function App() {
827833
}
828834
```
829835
836+
See [`jumpTo`](drawer-actions.md#jumpto) for more details.
837+
830838
### Hooks
831839
832840
The drawer navigator exports the following hooks:

versioned_docs/version-7.x/getting-started.md

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,7 @@ sidebar_label: Getting started
77
import Tabs from '@theme/Tabs';
88
import TabItem from '@theme/TabItem';
99

10-
The _Fundamentals_ section covers the most important aspects of React Navigation. It should be enough to build a typical mobile application and give you the background to dive deeper into the more advanced topics.
11-
12-
<details>
13-
<summary>Prior knowledge</summary>
14-
15-
If you're already familiar with JavaScript, React and React Native, you'll be able to get moving with React Navigation quickly! If not, we recommend gaining some basic knowledge first, then coming back here when you're done.
16-
17-
1. [React Documentation](https://react.dev/learn)
18-
2. [React Native Documentation](https://reactnative.dev/docs/getting-started)
19-
20-
</details>
21-
22-
<details>
23-
<summary>Minimum requirements</summary>
24-
25-
- `react-native` >= 0.72.0
26-
- `expo` >= 52 (if you use [Expo Go](https://expo.dev/go))
27-
- `typescript` >= 5.0.0 (if you use TypeScript)
28-
29-
</details>
10+
React Navigation is a navigation library for React Native and Web. It provides routing logic and UI common on mobile apps and PWAs with type-safe navigation, built-in universal links on mobile, and browser history integration on the web.
3011

3112
## Starter template
3213

@@ -48,6 +29,15 @@ In your project directory, run:
4829
npm install @react-navigation/native
4930
```
5031

32+
<details>
33+
<summary>Minimum requirements</summary>
34+
35+
- `react-native` >= 0.72.0
36+
- `expo` >= 52 (if you use [Expo Go](https://expo.dev/go))
37+
- `typescript` >= 5.0.0 (if you use TypeScript)
38+
39+
</details>
40+
5141
### Installing dependencies
5242

5343
Next, install the dependencies used by most navigators: [`react-native-screens`](https://github.com/software-mansion/react-native-screens) and [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context).
@@ -160,6 +150,8 @@ In `AndroidManifest.xml`, set `android:enableOnBackInvokedCallback` to `false` i
160150

161151
## Setting up React Navigation
162152

153+
The guides linked below cover the fundamentals of React Navigation, and give you the background to dive deeper into the more advanced topics.
154+
163155
When using React Navigation, you configure [**navigators**](glossary-of-terms.md#navigator) in your app. Navigators handle transitions between screens and provide UI such as headers, tab bars, etc.
164156

165157
There are 2 ways to configure navigators:
@@ -172,6 +164,6 @@ There are 2 ways to configure navigators:
172164

173165
- **[Dynamic configuration](hello-react-navigation.md?config=dynamic)**
174166

175-
Component-based configuration with significantly more boilerplate. Supports dynamic screen lists and navigator options.
167+
Component-based configuration with significantly more boilerplate for TypeScript and deep linking. Supports dynamic screen lists and navigator options.
176168

177169
</div>

versioned_docs/version-7.x/material-top-tab-navigator.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,8 @@ export default function App() {
659659
}
660660
```
661661
662+
See [`jumpTo`](tab-actions.md#jumpto) for more details.
663+
662664
### Hooks
663665
664666
The material top tab navigator exports the following hooks:

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,8 @@ Replaces the current screen with a new screen in the stack. The method accepts t
13131313
navigation.replace('Profile', { owner: 'Michaś' });
13141314
```
13151315
1316+
See [`replace`](stack-actions.md#replace) for more details.
1317+
13161318
#### `push`
13171319
13181320
Pushes a new screen to the top of the stack and navigate to it. The method accepts the following arguments:
@@ -1324,6 +1326,8 @@ Pushes a new screen to the top of the stack and navigate to it. The method accep
13241326
navigation.push('Profile', { owner: 'Michaś' });
13251327
```
13261328
1329+
See [`push`](stack-actions.md#push) for more details.
1330+
13271331
#### `pop`
13281332
13291333
Pops the current screen from the stack and navigates back to the previous screen. It takes one optional argument (`count`), which allows you to specify how many screens to pop back by.
@@ -1332,6 +1336,8 @@ Pops the current screen from the stack and navigates back to the previous screen
13321336
navigation.pop();
13331337
```
13341338
1339+
See [`pop`](stack-actions.md#pop) for more details.
1340+
13351341
#### `popTo`
13361342
13371343
Navigates back to a previous screen in the stack by popping screens after it. The method accepts the following arguments:
@@ -1347,6 +1353,8 @@ If a matching screen is not found in the stack, this will pop the current screen
13471353
navigation.popTo('Profile', { owner: 'Michaś' });
13481354
```
13491355
1356+
See [`popTo`](stack-actions.md#popto) for more details.
1357+
13501358
#### `popToTop`
13511359
13521360
Pops all of the screens in the stack except the first one and navigates to it.
@@ -1355,6 +1363,8 @@ Pops all of the screens in the stack except the first one and navigates to it.
13551363
navigation.popToTop();
13561364
```
13571365
1366+
See [`popToTop`](stack-actions.md#poptotop) for more details.
1367+
13581368
### Hooks
13591369
13601370
The native stack navigator exports the following hooks:

0 commit comments

Comments
 (0)