mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-11 22:33:32 +08:00
feat: export underlying views used to build navigators (#191)
Exporting the underlying views makes it easy to build custom navigators on top of our views. Libraries such as react-native-router-flux rely on such exports to build custom routing solutions while being able to take advantage of our work. This can also be the solution to adding custom behaviour without us needing to add separate config to override the router.
This commit is contained in:
committed by
Michał Osadnik
parent
c7a5cfd5b2
commit
d618ab382e
@@ -3,6 +3,11 @@
|
||||
*/
|
||||
export { default as createNativeStackNavigator } from './navigators/createNativeStackNavigator';
|
||||
|
||||
/**
|
||||
* Views
|
||||
*/
|
||||
export { default as NativeStackView } from './views/NativeStackView';
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
screensEnabled,
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
} from 'react-native-screens';
|
||||
import StackView from '../views/StackView';
|
||||
import NativeStackView from '../views/NativeStackView';
|
||||
import {
|
||||
NativeStackNavigatorProps,
|
||||
NativeStackNavigationOptions,
|
||||
@@ -64,11 +64,11 @@ function NativeStackNavigator(props: NativeStackNavigatorProps) {
|
||||
);
|
||||
|
||||
return (
|
||||
<StackView
|
||||
<NativeStackView
|
||||
{...rest}
|
||||
state={state}
|
||||
navigation={navigation}
|
||||
descriptors={descriptors}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,11 @@ type Props = {
|
||||
descriptors: NativeStackDescriptorMap;
|
||||
};
|
||||
|
||||
export default function StackView({ state, navigation, descriptors }: Props) {
|
||||
export default function NativeStackView({
|
||||
state,
|
||||
navigation,
|
||||
descriptors,
|
||||
}: Props) {
|
||||
return (
|
||||
<ScreenStack style={styles.scenes}>
|
||||
{state.routes.map(route => {
|
||||
Reference in New Issue
Block a user