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 { createNavigatorFactory, useNavigationBuilder } from '@react-navigation/core';
|
19 | import { StackRouter } from '@react-navigation/routers';
|
20 |
|
21 | function StackNavigator({ initialRouteName, children, ...rest }) {
|
22 | const { state, navigation, descriptors } = useNavigationBuilder(StackRouter, {
|
23 | initialRouteName,
|
24 | children,
|
25 | });
|
26 |
|
27 | return (
|
28 | <StackView
|
29 | state={state}
|
30 | navigation={navigation}
|
31 | descriptors={descriptors}
|
32 | {...rest}
|
33 | />
|
34 | );
|
35 | }
|
36 |
|
37 | export default createNavigatorFactory(StackNavigator);
|
38 | ```
|