Skip to content

Commit 7cef56c

Browse files
committed
Update docs with recent changes
1 parent e423591 commit 7cef56c

9 files changed

Lines changed: 220 additions & 63 deletions

File tree

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,25 @@ Style object for header. Supported properties:
753753

754754
- `backgroundColor`
755755

756+
#### `unstable_headerInsets`
757+
758+
Which edges of the native header apply window insets (e.g. statusbar inset) on Android.
759+
760+
The native header applies insets to every edge by default. Setting an edge to `false` removes the inset for that edge:
761+
762+
```js
763+
unstable_headerInsets: {
764+
top: false,
765+
bottom: false,
766+
}
767+
```
768+
769+
Supported edges are `top`, `left`, `right`, and `bottom`.
770+
771+
Disabling an inset also disables it for nested headers. A nested header cannot re-enable an inset disabled by a parent header.
772+
773+
This API may change in a minor release. Only supported on Android.
774+
756775
#### `headerShadowVisible`
757776

758777
Whether to hide the elevation shadow (Android) or the bottom border (iOS) on the header.

versioned_docs/version-7.x/screen.md

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@ A screen represents routes in a navigator. A screen's configuration contains the
1414

1515
Screens can be defined under the `screens` key in the navigator configuration:
1616

17+
```js
18+
const Stack = createNativeStackNavigator({
19+
screens: {
20+
Home: createNativeStackScreen({
21+
screen: HomeScreen,
22+
}),
23+
Profile: createNativeStackScreen({
24+
screen: ProfileScreen,
25+
}),
26+
},
27+
});
28+
```
29+
30+
The [`createXScreen`](static-configuration.md#createxscreen) helper is optional, but necessary for type inference in screen configuration callbacks such as `options`, `listeners`, etc.
31+
32+
A shorthand syntax is also supported where the screen component is used directly instead of a configuration object:
33+
1734
```js
1835
const MyStack = createNativeStackNavigator({
1936
screens: {
@@ -61,9 +78,9 @@ The key in the `screens` object is used as the name:
6178
const Stack = createNativeStackNavigator({
6279
screens: {
6380
// highlight-next-line
64-
Profile: {
81+
Profile: createNativeStackScreen({
6582
screen: ProfileScreen,
66-
},
83+
}),
6784
},
6885
});
6986
```
@@ -104,14 +121,14 @@ Options are used to configure how the screen gets presented in the navigator. It
104121
```js
105122
const Stack = createNativeStackNavigator({
106123
screens: {
107-
Profile: {
124+
Profile: createNativeStackScreen({
108125
screen: ProfileScreen,
109126
// highlight-start
110127
options: {
111128
title: 'Awesome app',
112129
},
113130
// highlight-end
114-
},
131+
}),
115132
},
116133
});
117134
```
@@ -142,14 +159,14 @@ When you pass a function, it'll receive the [`route`](route-object.md), [`naviga
142159
```js
143160
const Stack = createNativeStackNavigator({
144161
screens: {
145-
Profile: {
162+
Profile: createNativeStackScreen({
146163
screen: ProfileScreen,
147164
// highlight-start
148165
options: ({ route, navigation, theme }) => ({
149166
title: route.params.userId,
150167
}),
151168
// highlight-end
152-
},
169+
}),
153170
},
154171
});
155172
```
@@ -184,11 +201,11 @@ Initial params are used as the default params for the screen. If a screen is use
184201
```js
185202
const Stack = createNativeStackNavigator({
186203
screens: {
187-
Details: {
204+
Details: createNativeStackScreen({
188205
screen: DetailsScreen,
189206
// highlight-next-line
190207
initialParams: { itemId: 42 },
191-
},
208+
}),
192209
},
193210
});
194211
```
@@ -220,11 +237,11 @@ This can be done by specifying the `getId` callback. It receives an object with
220237
```js
221238
const Stack = createStackNavigator({
222239
screens: {
223-
Profile: {
240+
Profile: createStackScreen({
224241
screen: ProfileScreen,
225242
// highlight-next-line
226243
getId: ({ params }) => params.userId,
227-
},
244+
}),
228245
},
229246
});
230247
```
@@ -273,10 +290,10 @@ It can be passed under the `screen` property in the screen configuration:
273290
```js
274291
const Stack = createNativeStackNavigator({
275292
screens: {
276-
Profile: {
293+
Profile: createNativeStackScreen({
277294
// highlight-next-line
278295
screen: ProfileScreen,
279-
},
296+
}),
280297
},
281298
});
282299
```
@@ -308,7 +325,7 @@ It's also possible to pass a function in the `getComponent` prop to lazily evalu
308325
/>
309326
```
310327

311-
You can use this approach instead of the `component` prop if you want the `ProfileScreen` module to be lazily evaluated when needed. This is especially useful when using [ram bundles](https://reactnative.dev/docs/ram-bundles-inline-requires) to improve initial load.
328+
You can use this approach instead of the `component` prop if you want the `ProfileScreen` module to be lazily evaluated with [inline requires](https://reactnative.dev/docs/optimizing-javascript-loading#advanced-call-require-inline).
312329

313330
#### `children`
314331

@@ -344,7 +361,7 @@ It takes a function that returns a React element:
344361
```js
345362
const Stack = createNativeStackNavigator({
346363
screens: {
347-
Profile: {
364+
Profile: createNativeStackScreen({
348365
screen: ProfileScreen,
349366
// highlight-start
350367
layout: ({ children }) => (
@@ -361,7 +378,7 @@ const Stack = createNativeStackNavigator({
361378
</ErrorBoundary>
362379
),
363380
// highlight-end
364-
},
381+
}),
365382
},
366383
});
367384
```
@@ -408,11 +425,11 @@ This can be useful when we have some screens that we want to be removed or reset
408425
```js
409426
const Stack = createNativeStackNavigator({
410427
screens: {
411-
Profile: {
428+
Profile: createNativeStackScreen({
412429
screen: ProfileScreen,
413430
// highlight-next-line
414431
navigationKey: 'user',
415-
},
432+
}),
416433
},
417434
});
418435
```

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ npm install @react-navigation/native@next
2222
<details>
2323
<summary>Minimum requirements</summary>
2424

25-
- `react-native` >= 0.83
26-
- `expo` >= 55 ([development build](https://docs.expo.dev/development/introduction/) is required)
25+
- `react-native` >= 0.86
26+
- `expo` >= 56 ([development build](https://docs.expo.dev/development/introduction/) is required)
2727
- `typescript` >= 6.0.0 (if you use TypeScript)
2828
- `react-native-web` >= 0.21.0 (if you support Web)
2929

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,25 @@ Style object for header. Supported properties:
764764

765765
- `backgroundColor`
766766

767+
#### `unstable_headerInsets`
768+
769+
Which edges of the native header apply window insets (e.g. statusbar inset) on Android.
770+
771+
The native header applies insets to every edge by default. Setting an edge to `false` removes the inset for that edge:
772+
773+
```js
774+
unstable_headerInsets: {
775+
top: false,
776+
bottom: false,
777+
}
778+
```
779+
780+
Supported edges are `top`, `left`, `right`, and `bottom`.
781+
782+
Disabling an inset also disables it for nested headers. A nested header cannot re-enable an inset disabled by a parent header.
783+
784+
This API may change in a minor release. Only supported on Android.
785+
767786
#### `headerShadowVisible`
768787

769788
Whether to hide the elevation shadow (Android) or the bottom border (iOS) on the header.

versioned_docs/version-8.x/navigation-container.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,12 +1085,18 @@ function MyComponent() {
10851085
### `persistor`
10861086
10871087
An object containing functions to persist and restore the [navigation state](navigation-state.md).
1088-
The `persistor` object should contain two functions:
10891088
1090-
- `persist` - Function that receives the navigation state as an argument and should save it to storage.
1091-
- `restore` - Function that returns the previously saved state from storage, or `undefined` if there's no saved state.
1089+
The `persistor` object should contain two required functions:
10921090
1093-
These function can be both synchronous or asynchronous. If a promise is returned from the `restore` function, make sure to provide a [`fallback`](navigation-container.md#fallback).
1091+
- `persist` - Function that receives the serialized navigation state and should save it to storage. The stored state should be removed if it receives `undefined`. It can be synchronous or return a promise.
1092+
- `restore` - Function that returns the previously saved serialized state, or `undefined` if there's no saved state. It can be synchronous or return a promise.
1093+
1094+
By default, the state is serialized with `JSON.stringify` and parsed with `JSON.parse`. You can override this by providing the following optional functions:
1095+
1096+
- `stringify` - Function that receives the navigation state and returns a serialized string or `undefined`.
1097+
- `parse` - Function that receives the serialized string and returns the parsed navigation state or `undefined`.
1098+
1099+
If a promise is returned from the `restore` function, make sure to provide a [`fallback`](navigation-container.md#fallback).
10941100
10951101
See [state persistence guide](state-persistence.md) for example usage.
10961102

versioned_docs/version-8.x/navigation-object.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,14 +1791,14 @@ const drawerNavigation = navigation.getParent('Dashboard');
17911791

17921792
// ...
17931793

1794-
drawerNavigation?.openDrawer();
1794+
drawerNavigation.openDrawer();
17951795
```
17961796
17971797
In this case, `'Dashboard'` refers to the name of a parent screen of `Feed` that's used in the parent drawer navigator.
17981798
17991799
This approach allows components to not have to know the nesting structure of the navigators. So it's highly recommended to use a screen name when using `getParent`.
18001800
1801-
This method will return `undefined` if there is no matching parent navigator.
1801+
When called without a screen name, this method returns `undefined` if there is no immediate parent navigator. When called with a screen name, it throws an error if that screen isn't found in the current or parent navigators.
18021802
18031803
### `getState`
18041804

0 commit comments

Comments
 (0)