feat: add an option to specify default options for the navigator

This commit is contained in:
Satyajit Sahoo
2020-11-17 20:25:49 +01:00
parent 6f326cf0c5
commit c85f2ff47a
4 changed files with 44 additions and 21 deletions

View File

@@ -29,14 +29,6 @@ function StackNavigator({
screenOptions,
...rest
}: Props) {
const defaultOptions = {
gestureEnabled: Platform.OS === 'ios',
animationEnabled:
Platform.OS !== 'web' &&
Platform.OS !== 'windows' &&
Platform.OS !== 'macos',
};
const { state, descriptors, navigation } = useNavigationBuilder<
StackNavigationState<ParamListBase>,
StackRouterOptions,
@@ -46,16 +38,14 @@ function StackNavigator({
>(StackRouter, {
initialRouteName,
children,
screenOptions:
typeof screenOptions === 'function'
? (...args) => ({
...defaultOptions,
...screenOptions(...args),
})
: {
...defaultOptions,
...screenOptions,
},
screenOptions,
defaultScreenOptions: {
gestureEnabled: Platform.OS === 'ios',
animationEnabled:
Platform.OS !== 'web' &&
Platform.OS !== 'windows' &&
Platform.OS !== 'macos',
},
});
React.useEffect(