mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-13 09:39:18 +08:00
The tests are being bundled and shipped in prod, this adds a bit of unneeded weight to npm installs. Now they won't be included. ``` @react-navigation/core - before: 274 files - pkg: 211.0 kB - unpkg: 1 MB - after: 238 files - pkg: 192.1 kB - unpkg: 827.3 kB ```
@react-navigation/core
Core utilities for building navigators independent of the platform.
Installation
Open a Terminal in your project's folder and run,
yarn add @react-navigation/core
Usage
A basic custom navigator bundling a router and a view looks like this:
import { createNavigatorFactory, 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 createNavigatorFactory(StackNavigator);