What could be a solution (not sure that it's the best one) would be to spend in the param object the previous screen. With that, if the params exists would mean that a previous screen exists.
For example:
const navigateAction = NavigationActions.navigate({
routeName: 'Profile',
params: { previous_screen: 'CURRENT_SCREEN' },
action: NavigationActions.navigate({ routeName: 'NEXT_SCREEN' }),
});
this.props.navigation.dispatch(navigateAction);
And then in the next screen:
const { navigation } = this.props;
if (navigation.state.params && navigation.state.params.previous_screen) {
// A previous screen exists
} else {
// No previous screen
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…