What I want is when user is not logged in click on the tabbarItem, then switch to login navigator! So how can I handle tabbarItem click?
There is a tabBarOnPress
options mentioned in react-navigation
: https://reactnavigation.org/docs/en/bottom-tab-navigator.html It may help you to achieve what you need.
Update: You can also declare navigationOptions
as a function like this, to get access to navigation
object:
navigationOptions: ({ navigation }) => ({
tabBarOnPress: event => {
navigation.dispatch(NavigationActions...)
// event.defaultHandler(); // This is the default handler from react-navigation (go to the tab)
},
...otherOptions
})