I'm working with React-Native-Navigation v2 for the first time, modeling a simple app that has 3 tabs at the bottom and a sidebar that has a button which will navigate to a fourth screen when pressed mimicking a 'logout'. This fourth tab will then have a button that mimics a 'login' by returning to the first screen which is part of the bottomTabs stack.
The code I have works, but only once. After I have logged out (pushing new screen to the stack) I can then log back in (popping that screen back off the stack). However when I try to logout again I'm not able to do it. The functionality to push to the stack seems to no longer work.
handleLogOutPress = () => {
Navigation.push('CenterStack', {
component: {
name: 'navigationApp.FourthTabScreen',
passProps: {
text: 'Logged Out'
},
options: {
topBar: {
visible: false
}
}
}
})
Navigation.mergeOptions('CenterStack', {
sideMenu: {
left: {
visible: false
}
}
})
}
function handleLoginPress(){
Navigation.pop('CenterStack')
}
This is how my stack is set up initially:
Navigation.setRoot({
root: {
sideMenu: {
left: {
component: {
id: 'SideMenu',
name: 'navigationApp.SideMenu'
}
},
center: {
stack: {
id: 'CenterStack',
children: [
{
bottomTabs: {
children: [
{
component: {
id: 'FirstTab',
name: 'navigationApp.FirstTabScreen',
passProps: {
text: 'Home',
id: 'FirstTab'
},
options: {
bottomTab: {
icon: images[0],
text: 'Home',
iconColor: 'darkblue',
selectedIconColor: 'lightblue'
},
topBar: {
visible: false
}
}
},
},
{
component: {
id: 'SecondTab',
name: 'navigationApp.SecondTabScreen',
passProps: {
text: 'Search',
id: 'SecondTab'
},
options: {
bottomTab: {
icon: images[1],
text: 'Search',
iconColor: 'darkblue',
selectedIconColor: 'lightblue'
},
topBar: {
visible: false
}
}
},
},
{
component: {
id: 'ThirdTab',
name: 'navigationApp.ThirdTabScreen',
passProps: {
text: 'Share',
id: 'ThirdTab'
},
options: {
bottomTab: {
icon: images[2],
text: 'Share',
iconColor: 'darkblue',
selectedIconColor: 'lightblue'
},
topBar: {
visible: false
}
}
}
},
],
}
}
],
},
}
}
}
})
I may be completely misunderstanding how push/pop works, any help and guidance is appreciated.