1

I am using the React native navigation v5 I create a header on separated file and that file use this in stack header

make a button for open drawer navigation

header file

OpenMenu=(navigation)=>{
  navigation.openDrawer();
  }
 export default function Header({navigation,title}) {
       return (
   <View  style={styles.container}>
 <MaterialIcons name="menu" size={28} onPress={()=> this.OpenMenu(navigation)} style={styles.icon}/> 
          <View  style={styles.header}>
        <View style={{alignItems:'center'}}>
        <Text style={styles.headerText}> {title} </Text>
        </View>
        </View>
       </View>  );}

use this header

<Stack.Screen name="Dashboard" component={Dashboard}
 options={{
 headerTitle:(navigation)=> <Header  navigation={navigation}  title={"Dashboard"}/>,
 headerStyle: { backgroundColor: '#88aa31', }, headerLeft: null,    }} />

can any tell me how can fix this issue

S. Hesam
  • 5,266
  • 3
  • 37
  • 59
waqas Riaz
  • 53
  • 2
  • 8
  • 1
    Have you tried `toggleDrawer` rather than `openDrawer`? – SenAnan Jun 19 '20 at 11:05
  • 1
    Check [this answer](https://stackoverflow.com/questions/61340284/is-is-possible-to-use-navigation-toggledrawer-in-navigation-options/61352295#61352295), it should solve your problem. – CevaComic Jun 19 '20 at 11:20
  • have you install this library...@react-navigation/drawer....and wrap your Screen componet in Drawer.Navigator container...https://reactnavigation.org/docs/drawer-based-navigation/ – Savinder Singh Jun 19 '20 at 11:21
  • Hi u can use use hook "useNavigation" to get the navigation prop instead of passing it – rashi jain Jun 19 '20 at 11:58

0 Answers0