I have created a custom drawer navigator using react navigation version: 5.X, But the current active tab is not getting highlighted in custom drawer menu.
Please find the below code images. And let me know in case I have made any mistake.
Navigator Code :
Custom Drawer Component :
Current Active Tab : Home
You can use DrawerItemList to display the Drawer.Screen defined in Drawer.Navigator, as below:-
1) Define your Drawer Navigator:-
<Drawer.Navigator drawerContentOptions={{ activeBackgroundColor: '#5cbbff', activeTintColor: '#ffffff' }} drawerContent={props => <CustomDrawerContent {...props} />}>
<Drawer.Screen name="Home" component={HomeScreen} options={{
drawerIcon: config => <Icon
size={23}
name={Platform.OS === 'android' ? 'md-list' : 'ios-list'}></Icon>
}} />
/>
2) In CustomDrawerContent function:-
<DrawerContentScrollView {...props} >
----- your custom header ----
<DrawerItemList {...props} />
----- add other custom components, if any ----
</DrawerContentScrollView>
That solves the issue for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With