UNPKG

925 BMarkdownView Raw
1# `@react-navigation/core`
2
3Core utilities for building navigators independent of the platform.
4
5## Installation
6
7Open a Terminal in your project's folder and run,
8
9```sh
10yarn add @react-navigation/core
11```
12
13## Usage
14
15A basic custom navigator bundling a router and a view looks like this:
16
17```js
18import {
19 createNavigatorFactory,
20 useNavigationBuilder,
21} from '@react-navigation/core';
22import { StackRouter } from '@react-navigation/routers';
23
24function StackNavigator({ initialRouteName, children, ...rest }) {
25 const { state, navigation, descriptors, NavigationContent } =
26 useNavigationBuilder(StackRouter, {
27 initialRouteName,
28 children,
29 });
30
31 return (
32 <NavigationContent>
33 <StackView
34 state={state}
35 navigation={navigation}
36 descriptors={descriptors}
37 {...rest}
38 />
39 </NavigationContent>
40 );
41}
42
43export default createNavigatorFactory(StackNavigator);
44```