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:
Satyajit Sahoo
2019-12-04 00:22:53 +01:00
committed by Michał Osadnik
parent c7a5cfd5b2
commit d618ab382e
13 changed files with 60 additions and 52 deletions

View File

@@ -3,6 +3,11 @@
*/
export { default as createNativeStackNavigator } from './navigators/createNativeStackNavigator';
/**
* Views
*/
export { default as NativeStackView } from './views/NativeStackView';
/**
* Types
*/

View File

@@ -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}
/>
);
}

View File

@@ -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 => {