I need to vary my transition based on the screen, so I had this before react-navigation 4:
const HomeStack = createStackNavigator({
Home: HomeScreen,
AScreen,
BScreen,
CScreen,
DScreen,
EScreen,
},
{
headerMode: 'none',
transitionConfig: (nav) => handleCustomTransition(nav),
}
Then something like:
const handleCustomTransition = ({scenes}) => {
const prevScene = scenes[scenes.length - 2];
const nextScene = scenes[scenes.length - 1];
const duration = 500;
if (prevScene
&& prevScene.route.routeName === 'AScreen'
&& nextScene.route.routeName === 'BScreen') {
return fromBottom(duration);
} else if (prevScene
&& prevScene.route.routeName === 'AScreen'
&& nextScene.route.routeName === 'CScreen') {
return fromBottom(duration);
}
return fromRight();
};
So if you're going A->B or A->C the animation is fromBottom() but if you're doing any other transition its fromRight().
Any suggestions on how to update this to the new style? I've read the docs which don't cover per-screen transitions and other pages are incomplete.