mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-05-30 09:30:43 +08:00
39 lines
771 B
Markdown
39 lines
771 B
Markdown
# `@react-navigation/core`
|
|
|
|
Core utilities for building navigators.
|
|
|
|
## Installation
|
|
|
|
Open a Terminal in your project's folder and run,
|
|
|
|
```sh
|
|
yarn add @react-navigation/core
|
|
```
|
|
|
|
## Usage
|
|
|
|
A basic custom navigator bundling a router and a view looks like this:
|
|
|
|
```js
|
|
import { useNavigationBuilder } from '@react-navigation/core';
|
|
import { StackRouter } from '@react-navigation/routers';
|
|
|
|
function StackNavigator({ initialRouteName, children, ...rest }) {
|
|
const { state, navigation, descriptors } = useNavigationBuilder(StackRouter, {
|
|
initialRouteName,
|
|
children,
|
|
});
|
|
|
|
return (
|
|
<StackView
|
|
state={state}
|
|
navigation={navigation}
|
|
descriptors={descriptors}
|
|
{...rest}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default createNavigator(StackNavigator);
|
|
```
|