Skip to content

Commit 2ee8548

Browse files
callmetwankelset
authored andcommitted
Pass transition and modal props to transitionConfigurer (react-navigation#2383)
* Pass transition and modal props to transitionConfigurer * Make arguments passed to transitionConfigurer required * Update docs with params passed to transitionConfigurer
1 parent 5e26ced commit 2ee8548

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

docs/api/navigators/StackNavigator.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ Visual options:
8585
- `screen` - Each screen has a header attached to it and the header fades in and out together with the screen. This is a common pattern on Android.
8686
- `none` - No header will be rendered.
8787
- `cardStyle` - Use this prop to override or extend the default style for an individual card in stack.
88-
- `transitionConfig` - Function to return an object that overrides default screen transitions.
88+
- `transitionConfig` - Function to return an object that is merged with the default screen transitions (take a look at TransitionConfig in [type definitions](https://github.com/react-community/react-navigation/blob/master/src/TypeDefinition.js)). Provided function will be passed the following arguments:
89+
- `transitionProps` - Transition props for the new screen.
90+
- `prevTransitionProps` - Transitions props for the old screen.
91+
- `isModal` - Boolean specifying if screen is modal.
8992
- `onTransitionStart` - Function to be invoked when the card transition animation is about to start.
9093
- `onTransitionEnd` - Function to be invoked once the card transition animation completes.
9194

src/views/CardStack/TransitionConfigs.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ function defaultTransitionConfig(
8484
}
8585

8686
function getTransitionConfig(
87-
transitionConfigurer?: () => TransitionConfig,
87+
transitionConfigurer?: (
88+
transitionProps: NavigationTransitionProps,
89+
prevTransitionProps: NavigationTransitionProps,
90+
isModal: boolean
91+
) => TransitionConfig,
8892
// props for the new screen
8993
transitionProps: NavigationTransitionProps,
9094
// props for the old screen
@@ -99,7 +103,7 @@ function getTransitionConfig(
99103
if (transitionConfigurer) {
100104
return {
101105
...defaultConfig,
102-
...transitionConfigurer(),
106+
...transitionConfigurer(transitionProps, prevTransitionProps, isModal),
103107
};
104108
}
105109
return defaultConfig;

0 commit comments

Comments
 (0)