Is there a possibility of nesting tab navigator inside a drawer navigator in react-native? when the hamburger menu icon is invoked,I want the drawer to cover the entire screen and implement Tab navigator inside of it. I need some help with this.
Asked
Active
Viewed 523 times
2

Aishwarya R M
- 123
- 1
- 10
-
Where do you want exactly implement Tab navigator? – kenodek Dec 12 '19 at 10:37
-
Hi. I want to implement the Tab navigator inside the drawer. – Aishwarya R M Dec 12 '19 at 10:38
-
https://reactnativecode.com/show-tab-navigator-inside-drawer-navigator/ . does this help? – Gaurav Roy Dec 12 '19 at 10:46
2 Answers
0
To cover the entire screen you can set the drawerWidth
to be the width of the screen. see how to get the screen width in react native documentation
You can use the contentComponent
to render the tab navigator:
import { createDrawerNavigator } from 'react-navigation-drawer'
import { Dimensions } from 'react-native'
import MyTabNavigator from 'path-to-my-tab-navigator'
const { width } = Dimensions.get('window')
const DrawerNavigator = createDrawerNavigator(
{
... // screens
},
{
drawerWidth: width
contentComponent: MyTabNavigator
}
)
See the documentation
0
Same problem. Firstly, I couldn't set Tab Navigation inside Drawer Navigation.
For that I used "React Native Tab View" you can install it from "https://www.npmjs.com/package/react-native-tab-view", its worked with me.
<Drawer.Navigator
drawerContent={(props) => <CustomDrawerComp {...props} />}>
<Drawer.Screen name="MainStack" component={MainStack} />
</Drawer.Navigator>
export const CustomDrawerComp = (props) => {
const {navigation} = props;
const layout = useWindowDimensions();
const [index, setIndex] = React.useState(0);
const [routes] = React.useState([
{ key: 'first', title: 'FIRST' },
{ key: 'second', title: 'SECOND' },
]);
return (
<TabView
navigationState={{ index, routes }}
renderScene={SceneMap({
first: FirstTab, << Add first tab view
second: SecondTab, << Add second tab view
})}
onIndexChange={setIndex}
initialLayout={{ width: layout.width }}
/>
);
};
Also, You might get a simple error after used it "Invariant Violation: requireNativeComponent: "RNCViewPager" was not found in the UIManager" it's very easy don't worry, You can solve it from "https://github.com/ptomasroos/react-native-scrollable-tab-view/issues/1050"
I hope that helping some one.