title: How to open drawer in react native using navigation.openDrawer()
body: <p>I wanted to create a burger icon to open drawer but has been unable to do so. I have included the icon button on the right of my header. Whenever I click it to open the drawer, it shows the error of undefined function. I have mentioned the error below.</p>
  <p>TypeError: navigation.openDrawer is not a function. (In 'navigation.openDrawer()', 'navigation.openDrawer' is undefined)</p>
  <p>This is App.js, in this I have mentioned the code for drawer using createDrawerNavigator()</p>
  <p><strong>App.js</strong></p>
  <pre><code>import React from 'react';
  import { NavigationContainer } from '@react-navigation/native';
  import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
  
  import PassengerScreen from './Passenger';
  import Lovedones from './Lovedones';
  import NewTab from './FirstScreen';
  
  
  import { createDrawerNavigator } from '@react-navigation/drawer';
  
  const Drawer = createDrawerNavigator();
  
  export default App=() =&gt; ( 
  &lt;NavigationContainer&gt;
      &lt;Drawer.Navigator initialRouteName=&quot;Passenger&quot; drawerPosition=&quot;right&quot; &gt; 
          &lt;Drawer.Screen name=&quot;Passenger&quot; component={PassengerScreen} options= {{ title:'Passenger'}} /&gt;
          &lt;Drawer.Screen name=&quot;Lovedones&quot; component={Lovedones} options= {{ title:'loved ones!!'}} /&gt;
          &lt;Drawer.Screen name=&quot;New Screen&quot; component={NewTab}  /&gt;
        &lt;/Drawer.Navigator&gt;
    &lt;/NavigationContainer&gt;
  );
  </code></pre>
  <p>This is AccountScreen.js, in this code, I have created the icon button to open the drawer using navigation.openDrawer()</p>
  <p><strong>AccountScreen.js</strong></p>
  <pre><code>import * as React from 'react';
  import { View, Text, StyleSheet, Button } from 'react-native';
  import { createStackNavigator } from '@react-navigation/stack';
  import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
  import Ionicons from 'react-native-vector-icons/Ionicons';
  import { createDrawerNavigator } from '@react-navigation/drawer';
  
  
  const Stack= createStackNavigator();
  
  Account = () =&gt; {
    return &lt;View style={styles.container}&gt;
      &lt;Text&gt;Hello!!&lt;/Text&gt;
    &lt;/View&gt;
  };
  export default AccountStack =(navigation)=&gt;(
            &lt;Stack.Navigator &gt;
              &lt;Stack.Screen name=&quot;Account&quot; component= {Account} options={{headerRight: () =&gt; (&lt;Ionicons.Button name=&quot;reorder-three&quot; color={&quot;#FF0000&quot;} size={40} backgroundColor= {&quot;none&quot;} onPress={() =&gt; navigation.openDrawer()}/&gt; )  }} /&gt;
            &lt;/Stack.Navigator&gt;
  );
  
  const styles = StyleSheet.create({
    container: {
      flex: 1,
      alignItems: 'center',
      justifyContent: 'center',
    },
  });
  </code></pre>
  <p>Kindly help me in identifying the error.</p>