I am looking desperately for a possibility to check if a previous screen exists in ReactNavigation.
Using this.props.navigation.goBack() returns
It's completely working for me.... If you want to find out previous route/screen name from navigation stack in react native app so you can use this function.
export const previousRouteName = (navigation) =>{
let navRoutes = navigation.dangerouslyGetParent().state.routes;
if (navRoutes.length >= 2){
return navRoutes[navRoutes.length - 2].routeName
}
return navigation.state.routeName
}
How to use?
previousRouteName(props.navigation);
Hope you like and helpful to you K00L ;)