1 | # `@react-navigation/core`
|
2 |
|
3 | Core utilities for building navigators independent of the platform.
|
4 |
|
5 | ## Installation
|
6 |
|
7 | Open a Terminal in your project's folder and run,
|
8 |
|
9 | ```sh
|
10 | yarn add @react-navigation/core
|
11 | ```
|
12 |
|
13 | ## Usage
|
14 |
|
15 | A basic custom navigator bundling a router and a view looks like this:
|
16 |
|
17 | ```js
|
18 | import {
|
19 | createNavigatorFactory,
|
20 | useNavigationBuilder,
|
21 | } from '@react-navigation/core';
|
22 | import { StackRouter } from '@react-navigation/routers';
|
23 |
|
24 | function 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 |
|
43 | export default createNavigatorFactory(StackNavigator);
|
44 | ```
|