Skip to content

Commit 39a3748

Browse files
docs: use native-stack in headers
1 parent 219bf92 commit 39a3748

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

static/examples/6.x/basic-header-config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as React from 'react';
22
import { View, Text } from 'react-native';
33
import { NavigationContainer } from '@react-navigation/native';
4-
import { createStackNavigator } from '@react-navigation/stack';
4+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

6-
const Stack = createStackNavigator();
6+
const Stack = createNativeStackNavigator();
77

88
function HomeScreen() {
99
return (

static/examples/6.x/custom-header-title-component.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { View, Text, Image } from 'react-native';
33
import { NavigationContainer } from '@react-navigation/native';
4-
import { createStackNavigator } from '@react-navigation/stack';
4+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

66
function HomeScreen() {
77
return (
@@ -20,7 +20,7 @@ function LogoTitle() {
2020
);
2121
}
2222

23-
const Stack = createStackNavigator();
23+
const Stack = createNativeStackNavigator();
2424

2525
function App() {
2626
return (

static/examples/6.x/header-styles.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { View, Text } from 'react-native';
33
import { NavigationContainer } from '@react-navigation/native';
4-
import { createStackNavigator } from '@react-navigation/stack';
4+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

66
function HomeScreen() {
77
return (
@@ -11,7 +11,7 @@ function HomeScreen() {
1111
);
1212
}
1313

14-
const Stack = createStackNavigator();
14+
const Stack = createNativeStackNavigator();
1515

1616
function App() {
1717
return (

static/examples/6.x/params-in-title.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { View, Text, Button } from 'react-native';
33
import { NavigationContainer } from '@react-navigation/native';
4-
import { createStackNavigator } from '@react-navigation/stack';
4+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

66
function HomeScreen({ navigation }) {
77
return (
@@ -26,7 +26,7 @@ function ProfileScreen({ navigation }) {
2626
);
2727
}
2828

29-
const Stack = createStackNavigator();
29+
const Stack = createNativeStackNavigator();
3030

3131
function App() {
3232
return (

static/examples/6.x/sharing-header-styles.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { View, Text } from 'react-native';
33
import { NavigationContainer } from '@react-navigation/native';
4-
import { createStackNavigator } from '@react-navigation/stack';
4+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

66
function HomeScreen() {
77
return (
@@ -11,7 +11,7 @@ function HomeScreen() {
1111
);
1212
}
1313

14-
const Stack = createStackNavigator();
14+
const Stack = createNativeStackNavigator();
1515

1616
function App() {
1717
return (

static/examples/6.x/updating-options-with-setoptions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { View, Text, Button } from 'react-native';
33
import { NavigationContainer } from '@react-navigation/native';
4-
import { createStackNavigator } from '@react-navigation/stack';
4+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
55

66
function HomeScreen({ navigation }) {
77
return (
@@ -15,7 +15,7 @@ function HomeScreen({ navigation }) {
1515
);
1616
}
1717

18-
const Stack = createStackNavigator();
18+
const Stack = createNativeStackNavigator();
1919

2020
function App() {
2121
return (

versioned_docs/version-6.x/headers.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ There are a couple of things to notice here:
114114

115115
## Sharing common `options` across screens
116116

117-
It is common to want to configure the header in a similar way across many screens. For example, your company brand color might be red and so you want the header background color to be red and tint color to be white. Conveniently, these are the colors we're using in our running example, and you'll notice that when you navigate to the `DetailsScreen` the colors go back to the defaults. Wouldn't it be awful if we had to copy the `options` header style properties from `HomeScreen` to `DetailsScreen`, and for every single screen component we use in our app? Thankfully, we do not. We can instead move the configuration up to the stack navigator under the prop `screenOptions`.
117+
It is common to want to configure the header in a similar way across many screens. For example, your company brand color might be red and so you want the header background color to be red and tint color to be white. Conveniently, these are the colors we're using in our running example, and you'll notice that when you navigate to the `DetailsScreen` the colors go back to the defaults. Wouldn't it be awful if we had to copy the `options` header style properties from `HomeScreen` to `DetailsScreen`, and for every single screen component we use in our app? Thankfully, we do not. We can instead move the configuration up to the native stack navigator under the prop `screenOptions`.
118118

119119
<samp id="sharing-header-styles">sharing header styles</samp>
120120

@@ -173,14 +173,14 @@ function StackScreen() {
173173
}
174174
```
175175

176-
> You might be wondering, why `headerTitle` when we provide a component and not `title`, like before? The reason is that `headerTitle` is a property that is specific to a stack navigator, the `headerTitle` defaults to a `Text` component that displays the `title`.
176+
> You might be wondering, why `headerTitle` when we provide a component and not `title`, like before? The reason is that `headerTitle` is a property that is specific to a native stack navigator, the `headerTitle` defaults to a `Text` component that displays the `title`.
177177
178178
## Additional configuration
179179

180-
You can read the full list of available `options` for screens inside of a stack navigator in the [`createStackNavigator` reference](stack-navigator.md#navigationoptions-used-by-stacknavigator).
180+
You can read the full list of available `options` for screens inside of a native stack navigator in the [`createNativeStackNavigator` reference](native-stack-navigator#options).
181181

182182
## Summary
183183

184-
- You can customize the header inside of the `options` prop of your screen components. Read the full list of options [in the API reference](stack-navigator.md#navigationoptions-used-by-stacknavigator).
184+
- You can customize the header inside of the `options` prop of your screen components. Read the full list of options [in the API reference](native-stack-navigator#options).
185185
- The `options` prop can be an object or a function. When it is a function, it is provided with an object with the `navigation` and `route` prop.
186186
- You can also specify shared `screenOptions` in the stack navigator configuration when you initialize it. The prop takes precedence over that configuration.

0 commit comments

Comments
 (0)