I am trying to have a DrawerNavigator when user taps on the last tab(for example 'More') in TabNavigator.
How is this possible to achieve it without having a screen for that tab and then calling the DrawerNavigator in componentWillMount.
componentWillMount() {
this.props.navigation.navigate("DrawerOpen")
}
It is kind of a hack which is not proper solution I think(This way 'More' screen is loaded), there has to be a better solution for that.
This is also a bit of hack but I think its the simplest hack without using a custom TabBar or redux.
What you can do is to create a screen component rendering null
Then add this screen to your
TabNavigator
, import TabBars from react-navigation and toggle drawer for certain index.This way you simple continue using default TabBars from react-navigation, have an icon/label for your drawer and use it to toggle drawer.
You need to implement custom
tabBarComponent
for TabNavigator. It's a normal component you provide in the options.Then in the component, you just define
onPress
for the "More" button, which opens the drawer.It's as simple as that.