Intro
Just like Facebook, Instagram, and any other mobile app, I want to implement 'go back to initial screen in Stacknavigator'
- if user press the button,
- it goes back to the very first page.
Simple Use Case
- see TabNavigator
- Goes to 'Feed' Tab
- Goes to 'User' Screen
- Goes to another 'User' Screen
- PRESS the Main Tab Icon - 'Feed'}
- Goes BACK to 'Feed' Tab // so you won't see the 'back' button
And please leave a comment if you don't understand this use case, I will draw its state flow for you
Code for the icon on my Main TabNavigator.
navigationOptions: ({ navigation }) => ({
header: null,
tabBarIcon: ({ focused }) => {
const { routeName } = navigation.state;
....
return (
<TochableWithoutFeedback onPress={()=>{navigation.goback(iconName)}>
// undefined is not a function when I press the Button
// deeper screen. (not getting any error on Main)
<Ionicons
name={iconName}
size={30}
style={{ marginBottom: -3 }}
color={focused ? Colors.tabIconSelected : Colors.tabIconDefault}
/>
<TochableWithoutFeedback>
);
},