Skip to content

Commit 5f40057

Browse files
committed
Update more outdated documentation for 8.x
1 parent fed51a6 commit 5f40057

8 files changed

Lines changed: 95 additions & 58 deletions

File tree

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,21 +305,18 @@ type MyNavigationEventMap = {
305305
export type MyNavigationProp<
306306
ParamList extends ParamListBase,
307307
RouteName extends keyof ParamList = keyof ParamList,
308-
NavigatorID extends string | undefined = undefined,
309308
> = NavigationProp<
310309
ParamList,
311310
RouteName,
312-
NavigatorID,
313311
TabNavigationState<ParamList>,
314312
MyNavigationOptions,
315-
MyNavigationEventMap
316-
> &
317-
TabActionHelpers<ParamList>;
313+
MyNavigationEventMap,
314+
TabActionHelpers<ParamList>
315+
>;
318316

319317
// The props accepted by the component is a combination of 3 things
320318
type Props = DefaultNavigatorOptions<
321319
ParamListBase,
322-
string | undefined,
323320
TabNavigationState<ParamListBase>,
324321
MyNavigationOptions,
325322
MyNavigationEventMap,
@@ -470,7 +467,6 @@ import MyRouter from './MyRouter';
470467

471468
const { state, descriptors, navigation, NavigationContent } =
472469
useNavigationBuilder(MyRouter, {
473-
id,
474470
initialRouteName,
475471
children,
476472
layout,

versioned_docs/version-8.x/custom-routers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ The library ships with a few standard routers:
152152

153153
There are two main ways to customize routers:
154154

155-
- Override an existing router with the [`UNSTABLE_router`](navigator.md#router) prop on navigators
155+
- Override an existing router with the [`router`](navigator.md#router) prop on navigators
156156
- Customized navigators with a custom router, see [extending navigators](custom-navigators.md#extending-navigators)
157157

158158
### Custom Navigation Actions

versioned_docs/version-8.x/elements.md

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Usage:
2727

2828
```js name="React Navigation Elements Header" snack
2929
import * as React from 'react';
30-
import { SafeAreaProviderCompat } from '@react-navigation/elements';
30+
import { SafeAreaProvider } from 'react-native-safe-area-context';
3131
import { NavigationContainer } from '@react-navigation/native';
3232
// codeblock-focus-start
3333
import { Header } from '@react-navigation/elements';
@@ -40,9 +40,9 @@ function MyHeader() {
4040
export default function App() {
4141
return (
4242
<NavigationContainer>
43-
<SafeAreaProviderCompat>
43+
<SafeAreaProvider>
4444
<MyHeader />
45-
</SafeAreaProviderCompat>
45+
</SafeAreaProvider>
4646
</NavigationContainer>
4747
);
4848
}
@@ -704,14 +704,6 @@ It can also be a function that returns a React Element to render any component:
704704
/>
705705
```
706706

707-
### `MissingIcon`
708-
709-
A component that renders a missing icon symbol. It can be used as a fallback for icons to show that there's a missing icon. It accepts the following props:
710-
711-
- `color` - Color of the icon.
712-
- `size` - Size of the icon.
713-
- `style` - Additional styles for the icon.
714-
715707
### `PlatformPressable`
716708

717709
A component which provides an abstraction on top of [`Pressable`](https://reactnative.dev/docs/Pressable) to handle platform differences. In addition to `Pressable`'s props, it accepts following additional props:
@@ -816,16 +808,6 @@ Usage:
816808

817809
## Utilities
818810

819-
### `SafeAreaProviderCompat`
820-
821-
A wrapper over the `SafeAreaProvider` component from [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context) which includes initial values.
822-
823-
Usage:
824-
825-
```js
826-
<SafeAreaProviderCompat>{/* Your components */}</SafeAreaProviderCompat>
827-
```
828-
829811
### `HeaderBackContext`
830812

831813
React context that can be used to get the back title of the parent screen.

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

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,57 @@ String indicating whether the keyboard gets dismissed in response to a drag gest
151151
- `'on-drag'`: the keyboard is dismissed when a drag begins.
152152
- `'none'`: drags do not dismiss the keyboard.
153153

154-
#### `overScrollMode`
154+
#### `adapter`
155155

156-
Used to override default value of pager's overScroll mode.
156+
Function that renders a custom adapter for rendering pages. By default, the material top tab navigator uses [`react-native-pager-view`](https://github.com/callstack/react-native-pager-view) for rendering pages on Android and iOS. However, it may not be suitable for all use cases.
157157

158-
Possible values:
158+
You can use built-in adapters from [`react-native-tab-view`](tab-view.md#renderadapter) or create your own custom adapter.
159159

160-
- `'auto'` (default): Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll.
161-
- `'always'`: Always allow a user to over-scroll this view.
162-
- `'never'`: Never allow a user to over-scroll this view.
160+
To pass adapter-specific props, wrap the adapter in a function and forward the navigator props:
163161

164-
Only supported on Android.
162+
```js name="Material Top Tab Navigator adapter" snack static2dynamic
163+
import { Platform, Text, View } from 'react-native';
164+
import { createStaticNavigation } from '@react-navigation/native';
165+
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';
166+
import { PagerViewAdapter, ScrollViewAdapter } from 'react-native-tab-view';
167+
168+
function HomeScreen() {
169+
return (
170+
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
171+
<Text>Home Screen</Text>
172+
</View>
173+
);
174+
}
175+
176+
function ProfileScreen() {
177+
return (
178+
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
179+
<Text>Profile Screen</Text>
180+
</View>
181+
);
182+
}
183+
184+
const MyTabs = createMaterialTopTabNavigator({
185+
adapter: (props) =>
186+
Platform.OS === 'android' ? (
187+
<PagerViewAdapter {...props} overScrollMode="never" pageMargin={8} />
188+
) : (
189+
<ScrollViewAdapter {...props} bounces />
190+
),
191+
screens: {
192+
Home: HomeScreen,
193+
Profile: ProfileScreen,
194+
},
195+
});
196+
197+
const Navigation = createStaticNavigation(MyTabs);
198+
199+
export default function App() {
200+
return <Navigation />;
201+
}
202+
```
203+
204+
`PagerViewAdapter` accepts props from [`react-native-pager-view`](https://github.com/callstack/react-native-pager-view), such as `overScrollMode` and `pageMargin`. `ScrollViewAdapter` accepts [scroll view](https://reactnative.dev/docs/scrollview) props such as `bounces`.
165205

166206
#### `style`
167207

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ Supported values:
381381
- `vertical` – dismiss screen vertically
382382
- `horizontal` – dismiss screen horizontally (default)
383383

384-
When using `vertical` option, options `fullScreenGestureEnabled: true`, `customAnimationOnGesture: true` and `animation: 'slide_from_bottom'` are set by default.
384+
If you want the gesture to work on the whole screen or match a specific animation, configure `fullScreenGestureEnabled`, `customAnimationOnGesture`, and `animation` explicitly.
385385

386386
Only supported on iOS.
387387

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,12 @@ The `preload` method allows preloading a screen in the background before navigat
717717

718718
- `name` - _string_ - A destination name of the screen in the current or a parent navigator.
719719
- `params` - _object_ - Params to use for the destination route.
720+
- `options` - Options object containing the following properties:
721+
- `reuse` - _boolean_ - Whether to reuse a matching preloaded or existing route instead of adding a new preloaded route. Defaults to `false`.
722+
723+
```js
724+
navigation.preload('Profile', { user: 'jane' }, { reuse: true });
725+
```
720726

721727
<Tabs groupId="config" queryString="config">
722728
<TabItem value="static" label="Static" default>
@@ -911,7 +917,7 @@ Preloading a screen means that the screen will be rendered in the background. Al
911917

912918
Depending on the navigator, `preload` may work slightly differently:
913919

914-
- In a stack navigator ([stack](stack-navigator.md), [native stack](native-stack-navigator.md)), the screen will be rendered off-screen and animated in when you navigate to it. If [`getId`](screen.md#id) is specified, it'll be used for the navigation to identify the preloaded screen.
920+
- In a stack navigator ([stack](stack-navigator.md), [native stack](native-stack-navigator.md)), the screen will be rendered off-screen and animated in when you navigate to it. If [`getId`](screen.md#id) is specified, it'll be used for the navigation to identify the preloaded screen. When `reuse` is `true`, a matching preloaded or existing route will be reused and its params will be updated.
915921
- In a tab or drawer navigator ([bottom tabs](bottom-tab-navigator.md), [material top tabs](material-top-tab-navigator.md), [drawer](drawer-navigator.md), etc.), the existing screen will be rendered as if `lazy` was set to `false`. Calling `preload` on a screen that is already rendered will not have any effect.
916922

917923
### `setParams`

versioned_docs/version-8.x/static-configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The bulk of the static configuration is done using the `createXNavigator` functi
1010

1111
The `createXNavigator` functions take one argument, which is an object with the following properties:
1212

13-
- Same props as the navigator component, e.g. `id`, `initialRouteName`, `screenOptions` etc. See [Navigator](navigator.md) as well as the docs for each navigator for more details on the props they accept.
13+
- Same props as the navigator component, e.g. `initialRouteName`, `screenOptions` etc. See [Navigator](navigator.md) as well as the docs for each navigator for more details on the props they accept.
1414
- `screens` - an object containing configuration for each screen in the navigator.
1515
- `groups` - an optional object containing groups of screens (equivalent to [`Group`](group.md) in the dynamic API).
1616

versioned_docs/version-8.x/tab-view.md

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,7 @@ Example:
256256

257257
```js
258258
import * as React from 'react';
259-
import {
260-
Animated,
261-
StyleSheet,
262-
TouchableOpacity,
263-
View,
264-
} from 'react-native';
259+
import { Animated, StyleSheet, TouchableOpacity, View } from 'react-native';
265260
import { SceneMap, TabView } from 'react-native-tab-view';
266261

267262
const FirstRoute = () => (
@@ -452,25 +447,13 @@ String indicating whether the keyboard gets dismissed in response to a drag gest
452447
- `'on-drag'`: the keyboard is dismissed when a drag begins.
453448
- `'none'`: drags do not dismiss the keyboard.
454449

455-
##### `overScrollMode`
456-
457-
Used to override default value of pager's overScroll mode.
458-
459-
Possible values:
460-
461-
- `'auto'` (default): Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll.
462-
- `'always'`: Always allow a user to over-scroll this view.
463-
- `'never'`: Never allow a user to over-scroll this view.
464-
465-
Only supported on Android.
466-
467450
##### `swipeEnabled`
468451

469452
Boolean indicating whether to enable swipe gestures. Swipe gestures are enabled by default. Passing `false` will disable swipe gestures, but the user can still switch tabs by pressing the tab bar.
470453

471454
##### `renderAdapter`
472455

473-
A function that returns a custom adapter for rendering pages. By default, `react-native-tab-view` uses [`react-native-pager-view`](https://github.com/callstack/react-native-pager-view) for rendering pages on Android and iOS. However, it may not be suitable for all use cases.
456+
Function that renders a custom adapter for rendering pages. By default, `react-native-tab-view` uses [`react-native-pager-view`](https://github.com/callstack/react-native-pager-view) for rendering pages on Android and iOS. However, it may not be suitable for all use cases.
474457

475458
You can use built-in adapters or create your own custom adapter. For example, you can use `ScrollViewAdapter` to use a `ScrollView` for rendering pages:
476459

@@ -498,6 +481,36 @@ The following built-in adapters are available:
498481
- `PanResponderAdapter`: Uses [`PanResponder`](https://reactnative.dev/docs/panresponder) for handling gestures (default on Web and other platforms).
499482
- `ScrollViewAdapter`: Uses [`ScrollView`](https://reactnative.dev/docs/scrollview) for rendering pages.
500483

484+
To pass adapter-specific props, wrap the adapter in a function and forward the `TabView` props:
485+
486+
```js
487+
import { Platform } from 'react-native';
488+
import {
489+
PagerViewAdapter,
490+
ScrollViewAdapter,
491+
TabView,
492+
} from 'react-native-tab-view';
493+
494+
function App() {
495+
return (
496+
<TabView
497+
navigationState={{ index, routes }}
498+
renderScene={renderScene}
499+
onIndexChange={setIndex}
500+
renderAdapter={(props) =>
501+
Platform.OS === 'android' ? (
502+
<PagerViewAdapter {...props} overScrollMode="never" pageMargin={8} />
503+
) : (
504+
<ScrollViewAdapter {...props} bounces />
505+
)
506+
}
507+
/>
508+
);
509+
}
510+
```
511+
512+
`PagerViewAdapter` accepts props from [`react-native-pager-view`](https://github.com/callstack/react-native-pager-view), such as `overScrollMode` and `pageMargin`. `ScrollViewAdapter` accepts [scroll view](https://reactnative.dev/docs/scrollview) props such as `bounces`, `decelerationRate`, and `keyboardShouldPersistTaps`.
513+
501514
You can also create your own custom adapter by implementing the required interface:
502515

503516
```ts

0 commit comments

Comments
 (0)