0

Recently I integrate drawer navigator in my React Native application and I used react native drawer version @react-navigation/drawer 6.6.2 and my project version in 0.69.5 below is my code

import 'react-native-gesture-handler';
import * as React from 'react';
import { Button, Text, View } from 'react-native';
import { createDrawerNavigator, useDrawerStatus } from '@react-navigation/drawer';
import { NavigationContainer } from '@react-navigation/native';

function HomeScreen({ navigation }) {
  const status = useDrawerStatus();
  console.log('  ----> status', status);

 return (
   <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
    <Button
    onPress={() => navigation.navigate('Notifications')}
    title="Go to notifications"
  />
  <Text>
    Status : {status}
  </Text>
  </View>
  );
 }

 function NotificationsScreen({ navigation }) {
  return (
  <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
    <Button onPress={() => navigation.goBack()} title="Go back home" />
   </View>
 );
}

const Drawer = createDrawerNavigator();

export default function App() {
 return (
  <NavigationContainer>
    <Drawer.Navigator initialRouteName="Home">
      <Drawer.Screen name="Home" component={HomeScreen} />
      <Drawer.Screen name="Notifications" component={NotificationsScreen} />
    </Drawer.Navigator>
  </NavigationContainer>
 );
}

When i run above code toggle function is not working so drawer is not opening . Any idea how can i solve this ?

Harshal Kalavadiya
  • 2,412
  • 4
  • 38
  • 71

0 Answers0