Skip to content

Commit 1e1f7f1

Browse files
committed
Various improvements
1 parent 77e80d2 commit 1e1f7f1

Some content is hidden

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

57 files changed

+360
-286
lines changed

versioned_docs/version-8.x/auth-flow.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ This means:
8888

8989
This makes it impossible to navigate to the `Home` when the user is not signed in, and to `SignIn` when the user is signed in.
9090

91-
When the values returned by `useIsSignedin` and `useIsSignedOut` change, the screens matching the condition will change:
91+
When the values returned by `useIsSignedIn` and `useIsSignedOut` change, the screens matching the condition will change:
9292

93-
- Let's say, initially `useIsSignedOut` returns `true`. This means that `SignIn` screens is shown.
93+
- Let's say, initially `useIsSignedOut` returns `true`. This means that the `SignIn` screen is shown.
9494
- After the user signs in, the return value of `useIsSignedIn` will change to `true` and `useIsSignedOut` will change to `false`, which means:
95-
- React Navigation will see that the `SignIn` screen is no longer matches the condition, so it will remove the screen.
95+
- React Navigation will see that the `SignIn` screen no longer matches the condition, so it will remove the screen.
9696
- Then it'll show the `Home` screen automatically because that's the first screen available when `useIsSignedIn` returns `true`.
9797

9898
The order of the screens matters when there are multiple screens matching the condition. For example, if there are two screens matching `useIsSignedIn`, the first screen will be shown when the condition is `true`.
@@ -170,14 +170,14 @@ This means:
170170

171171
This makes it impossible to navigate to the `Home` when the user is not signed in, and to `SignIn` when the user is signed in.
172172

173-
When the value of `isSignedin` changes, the screens defined based on the condition will change:
173+
When the value of `isSignedIn` changes, the screens defined based on the condition will change:
174174

175-
- Let's say, initially `isSignedin` is `false`. This means that `SignIn` screens is shown.
176-
- After the user signs in, the value of `isSignedin` will change to `true`, which means:
175+
- Let's say, initially `isSignedIn` is `false`. This means that the `SignIn` screen is shown.
176+
- After the user signs in, the value of `isSignedIn` will change to `true`, which means:
177177
- React Navigation will see that the `SignIn` screen is no longer defined, so it will remove the screen.
178-
- Then it'll show the `Home` screen automatically because that's the first screen defined when `isSignedin` returns `true`.
178+
- Then it'll show the `Home` screen automatically because that's the first screen defined when `isSignedIn` returns `true`.
179179

180-
The order of the screens matters when there are multiple screens matching the condition. For example, if there are two screens defined based on `isSignedin`, the first screen will be shown when the condition is `true`.
180+
The order of the screens matters when there are multiple screens matching the condition. For example, if there are two screens defined based on `isSignedIn`, the first screen will be shown when the condition is `true`.
181181

182182
</TabItem>
183183
</Tabs>
@@ -228,16 +228,15 @@ export default function App() {
228228
<NavigationContainer>
229229
<Stack.Navigator>
230230
{isSignedIn ? (
231+
<Stack.Screen name="Home" component={HomeScreen} />
232+
) : (
231233
<Stack.Screen
232234
name="SignIn"
233-
component={SimpleSignInScreen}
235+
component={SignInScreen}
234236
options={{
235237
title: 'Sign in',
236238
}}
237-
initialParams={{ setUserToken }}
238239
/>
239-
) : (
240-
<Stack.Screen name="Home" component={HomeScreen} />
241240
)}
242241
</Stack.Navigator>
243242
</NavigationContainer>
@@ -285,16 +284,15 @@ return (
285284
<NavigationContainer>
286285
<Stack.Navigator>
287286
{isSignedIn ? (
287+
<Stack.Screen name="Home" component={HomeScreen} />
288+
) : (
288289
<Stack.Screen
289290
name="SignIn"
290-
component={SimpleSignInScreen}
291+
component={SignInScreen}
291292
options={{
292293
title: 'Sign in',
293294
}}
294-
initialParams={{ setUserToken }}
295295
/>
296-
) : (
297-
<Stack.Screen name="Home" component={HomeScreen} />
298296
)}
299297
</Stack.Navigator>
300298
</NavigationContainer>
@@ -348,14 +346,14 @@ We can use [`React.Fragment`](https://react.dev/reference/react/Fragment) or [`G
348346
```js
349347
isSignedIn ? (
350348
<>
351-
<Stack.Screen name="SignIn" component={SignInScreen} />
352-
<Stack.Screen name="SignUp" component={SignUpScreen} />
353-
<Stack.Screen name="ResetPassword" component={ResetPassword} />
349+
<Stack.Screen name="Home" component={HomeScreen} />
350+
<Stack.Screen name="Profile" component={ProfileScreen} />
354351
</>
355352
) : (
356353
<>
357-
<Stack.Screen name="Home" component={HomeScreen} />
358-
<Stack.Screen name="Profile" component={ProfileScreen} />
354+
<Stack.Screen name="SignIn" component={SignInScreen} />
355+
<Stack.Screen name="SignUp" component={SignUpScreen} />
356+
<Stack.Screen name="ResetPassword" component={ResetPasswordScreen} />
359357
</>
360358
);
361359
```

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,11 @@ Example:
371371

372372
```js name="Search Tab on iOS 26" snack static2dynamic
373373
import * as React from 'react';
374-
import { View, Text, FlatList } from 'react-native';
375-
import { createStaticNavigation } from '@react-navigation/native';
374+
import { Platform, View, Text, FlatList } from 'react-native';
375+
import {
376+
createStaticNavigation,
377+
useNavigation,
378+
} from '@react-navigation/native';
376379
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
377380
import { createNativeStackNavigator } from '@react-navigation/native-stack';
378381

@@ -903,7 +906,8 @@ const Tabs = createBottomTabNavigator({
903906
```js
904907
<Tab.Navigator
905908
screenOptions={{
906-
tabBarPosition: dimensions.width < 600 ? 'bottom' : 'left',
909+
tabBarPosition: isLargeScreen ? 'left' : 'bottom',
910+
tabBarVariant: isLargeScreen ? 'material' : 'uikit',
907911
tabBarLabelPosition: 'below-icon',
908912
}}
909913
>
@@ -1326,7 +1330,7 @@ function MyComponent() {
13261330
const tabBarHeight = useBottomTabBarHeight();
13271331

13281332
return (
1329-
<ScrollView contentStyle={{ paddingBottom: tabBarHeight }}>
1333+
<ScrollView contentContainerStyle={{ paddingBottom: tabBarHeight }}>
13301334
{/* Content */}
13311335
</ScrollView>
13321336
);
@@ -1563,8 +1567,6 @@ Bottom Tab Navigator exposes various options to configure the transition animati
15631567
15641568
Putting these together, you can customize the transition animation for a screen:
15651569
1566-
Putting these together, you can customize the transition animation for a screen:
1567-
15681570
```js name="Bottom Tabs custom animation" snack static2dynamic
15691571
import * as React from 'react';
15701572
import { View, Text, Easing } from 'react-native';
@@ -1644,7 +1646,7 @@ import { TransitionSpecs } from '@react-navigation/bottom-tabs';
16441646
screen: Profile,
16451647
options: {
16461648
// highlight-start
1647-
transitionSpec: TransitionSpecs.CrossFadeSpec,
1649+
transitionSpec: TransitionSpecs.FadeSpec,
16481650
// highlight-end
16491651
},
16501652
},

versioned_docs/version-8.x/combine-static-with-dynamic.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const RootStack = createNativeStackNavigator({
3939
});
4040
```
4141

42-
Here, `FeedScreen` is a component that renders a tab navigator and is defined using the dynamic API:
42+
Here, `FeedScreen` is a component that renders a bottom tab navigator and is defined using the dynamic API:
4343

4444
```js
4545
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
@@ -58,8 +58,8 @@ function FeedScreen() {
5858

5959
This code will work, but we're missing 2 things:
6060

61-
- Linking configuration for the screens in the top tab navigator.
62-
- TypeScript types for the screens in the top tab navigator.
61+
- Linking configuration for the screens in the bottom tab navigator.
62+
- TypeScript types for the screens in the bottom tab navigator.
6363

6464
Since the nested navigator is defined using the dynamic API, we need to handle these manually. For the linking configuration, we can define the screens in the `linking` property of the `Feed` screen:
6565

versioned_docs/version-8.x/community-navigators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Community navigators
44
sidebar_label: Community navigators
55
---
66

7-
This guide lists various community navigators for React Navigation. These navigators offer provide UI components for navigation with the familiar React Navigation API.
7+
This guide lists various community navigators for React Navigation. These navigators provide UI components for navigation with the familiar React Navigation API.
88

99
If you're looking to build your own navigator, check out the [custom navigators guide](custom-navigators.md).
1010

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ const state = {
485485
sort: 'latest',
486486
},
487487
},
488-
];
488+
],
489489
}
490490
```
491491

@@ -655,7 +655,9 @@ const RootStack = createStackNavigator({
655655
date: (date) => {
656656
const d = new Date(date);
657657

658-
return d.getFullYear() + '-' + d.getMonth() + '-' + d.getDate();
658+
return (
659+
d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
660+
);
659661
},
660662
},
661663
},
@@ -687,7 +689,7 @@ const config = {
687689
date: (date) => {
688690
const d = new Date(date);
689691

690-
return d.getFullYear() + '-' + d.getMonth() + '-' + d.getDate();
692+
return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
691693
},
692694
},
693695
// highlight-end
@@ -803,7 +805,7 @@ const HomeTabs = createBottomTabNavigator({
803805
screen: FeedScreen,
804806
},
805807
Profile: {
806-
screen: HomeScreen,
808+
screen: ProfileScreen,
807809
linking: {
808810
path: 'users/:id',
809811
},
@@ -902,7 +904,7 @@ const HomeTabs = createBottomTabNavigator({
902904
screen: FeedScreen,
903905
},
904906
Profile: {
905-
screen: HomeScreen,
907+
screen: ProfileScreen,
906908
linking: {
907909
path: 'users/:id',
908910
},
@@ -1015,7 +1017,7 @@ const HomeTabs = createBottomTabNavigator({
10151017
screen: FeedScreen,
10161018
},
10171019
Profile: {
1018-
screen: HomeScreen,
1020+
screen: ProfileScreen,
10191021
linking: {
10201022
path: 'users/:id',
10211023
},
@@ -1119,7 +1121,7 @@ By default, paths defined for each screen are matched against the URL relative t
11191121
const ProfileTabs = createBottomTabNavigator({
11201122
screens: {
11211123
Profile: {
1122-
screen: HomeScreen,
1124+
screen: ProfileScreen,
11231125
linking: {
11241126
path: 'users/:id',
11251127
},
@@ -1171,7 +1173,7 @@ In this case, it makes more sense to navigate to the `Profile` screen using a UR
11711173
const ProfileTabs = createBottomTabNavigator({
11721174
screens: {
11731175
Profile: {
1174-
screen: HomeScreen,
1176+
screen: ProfileScreen,
11751177
linking: {
11761178
path: 'users/:id',
11771179
// highlight-next-line
@@ -1229,13 +1231,13 @@ Sometimes, you may not want to have the route name of a screen in the path. For
12291231
const RootStack = createStackNavigator({
12301232
screens: {
12311233
Home: {
1232-
screen: ProfileScreen,
1234+
screen: HomeScreen,
12331235
linking: {
12341236
path: 'home',
12351237
},
12361238
},
12371239
Profile: {
1238-
screen: HomeScreen,
1240+
screen: ProfileScreen,
12391241
linking: {
12401242
path: 'users/:id',
12411243
},
@@ -1272,13 +1274,13 @@ You can specify an empty string as path or not specify a path at all, and React
12721274
const RootStack = createStackNavigator({
12731275
screens: {
12741276
Home: {
1275-
screen: ProfileScreen,
1277+
screen: HomeScreen,
12761278
linking: {
12771279
path: '',
12781280
},
12791281
},
12801282
Profile: {
1281-
screen: HomeScreen,
1283+
screen: ProfileScreen,
12821284
linking: {
12831285
path: 'users/:id',
12841286
},
@@ -1386,7 +1388,7 @@ const config = {
13861388
</TabItem>
13871389
</Tabs>
13881390
1389-
You can also provide a your own function to serialize the params. For example, let's say that you want to use a DD-MM-YYYY format in the path instead of a timestamp:
1391+
You can also provide your own function to serialize the params. For example, let's say that you want to use a DD-MM-YYYY format in the path instead of a timestamp:
13901392
13911393
<Tabs groupId="config" queryString="config">
13921394
<TabItem value="static" label="Static" default>
@@ -1405,7 +1407,9 @@ const RootStack = createStackNavigator({
14051407
date: (date) => {
14061408
const d = new Date(date);
14071409

1408-
return d.getFullYear() + '-' + d.getMonth() + '-' + d.getDate();
1410+
return (
1411+
d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
1412+
);
14091413
},
14101414
},
14111415
},
@@ -1429,7 +1433,7 @@ const config = {
14291433
date: (date) => {
14301434
const d = new Date(date);
14311435

1432-
return d.getFullYear() + '-' + d.getMonth() + '-' + d.getDate();
1436+
return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
14331437
},
14341438
},
14351439
},
@@ -1446,7 +1450,7 @@ Depending on your requirements, you can use this functionality to parse and stri
14461450
14471451
If you need more complex matching logic, you can use regular expressions to match the path. For example, if you want to use the pattern `@username` to match a user's profile, you can use a regular expression to match the path. This allows you to have the same path pattern for multiple screens, but fine-tune the matching logic to be more specific for a particular screen.
14481452
1449-
Regular expressions can be specified between parentheses `(` and `)` in the after a param name. For example:
1453+
Regular expressions can be specified between parentheses `(` and `)` after a param name. For example:
14501454
14511455
<Tabs groupId="config" queryString="config">
14521456
<TabItem value="static" label="Static" default>

versioned_docs/version-8.x/contributing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ Much like the issue template, the [pull request template](https://github.com/rea
9898
- Run these commands in the terminal to download locally and install it:
9999

100100
```bash
101-
git clone https://github.com/<USERNAME>/navigation-ex.git
102-
cd navigation-ex
101+
git clone https://github.com/<USERNAME>/react-navigation.git
102+
cd react-navigation
103103
git remote add upstream https://github.com/react-navigation/react-navigation.git
104104
yarn
105105
```
@@ -134,7 +134,7 @@ yarn typescript --watch
134134

135135
### Run the Example App
136136

137-
The [example app](https://github.com/react-navigation/react-navigation/tree/main/packages/example) includes a variety of patterns and is used as a simple way for contributors to manually integration test changes.
137+
The [example app](https://github.com/react-navigation/react-navigation/tree/main/example) includes a variety of patterns and is used as a simple way for contributors to manually integration test changes.
138138

139139
While developing, you can run the [example app](https://github.com/react-navigation/react-navigation/tree/main/example) with [Expo](https://expo.io/) to test your changes:
140140

versioned_docs/version-8.x/custom-android-back-button-handling.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function ScreenWithCustomBackBehavior() {
6060
return (
6161
<View style={styles.container}>
6262
{listData.map((item) => (
63-
<>
63+
<React.Fragment key={item.key}>
6464
{isSelectionModeEnabled ? (
6565
<PlatformPressable
6666
onPress={() => {
@@ -85,7 +85,7 @@ function ScreenWithCustomBackBehavior() {
8585
{item.key}
8686
</Text>
8787
)}
88-
</>
88+
</React.Fragment>
8989
))}
9090
<Button
9191
onPress={() => setIsSelectionModeEnabled(!isSelectionModeEnabled)}
@@ -175,7 +175,7 @@ function ScreenWithCustomBackBehavior() {
175175
return (
176176
<View style={styles.container}>
177177
{listData.map((item) => (
178-
<>
178+
<React.Fragment key={item.key}>
179179
{isSelectionModeEnabled ? (
180180
<PlatformPressable
181181
onPress={() => {
@@ -200,7 +200,7 @@ function ScreenWithCustomBackBehavior() {
200200
{item.key}
201201
</Text>
202202
)}
203-
</>
203+
</React.Fragment>
204204
))}
205205
<Button
206206
onPress={() => setIsSelectionModeEnabled(!isSelectionModeEnabled)}

0 commit comments

Comments
 (0)