Is it possible to enable/disable the navigation transition animation based on a specifically passed param?
navigation.navigate('SomeScreen', {
data: someData,
withAnimation: true,
});
In the example above, the withAnimation
param is set to true
, so I want the animation (forRevealFromBottomAndroid
) set here to be active:
<Stack.Screen
name="SomeScreen"
component={SomeScreen}
options={{
headerLeft: null,
headerShown: false,
cardStyleInterpolator:
CardStyleInterpolators.forRevealFromBottomAndroid,
}}
/>
Yes it's possible. You can achieve it this way:
In your navigator:
<Stack.Screen
name="SomeScreen"
component={SomeScreen}
options={({route: {params}}) => ({
headerLeft: null,
headerShown: false,
cardStyleInterpolator: params?.withAnimation
? CardStyleInterpolators.forHorizontalIOS
: CardStyleInterpolators.forNoAnimation,
})}
/>
Where you navigate:
navigation.navigate('SomeScreen', {
data: someData,
withAnimation: true
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With