2

My code for the current scenario is as follows:

function DrawerNavigation(props) {
  return (
    <DrawerContentScrollView {...props}>
      <TouchableOpacity
        style={styles.colseIconContainer}
        onPress={() => props.navigation.closeDrawer()}>
        <IconButton
          icon={({size}) => (
            <Image
              source={require('../../../resource/images/CloseIcon.png')}
              style={{width: size, height: size}}
            />
          )}
          size={40}
        />
      </TouchableOpacity>
    </DrawerContentScrollView>
  );
}

const Drawer = createDrawerNavigator();

export default function MyDrawer(props) {
  return (
    <Drawer.Navigator
      drawerPosition="right"
      drawerContent={() => <DrawerNavigation {...props} />}
      drawerStyle={styles.drawerStyle}>
      <Drawer.Screen
        name="Home"
        component={HomeScreen}
        options={{swipeEnabled: true}}
        initialParams={props.navigation}
      />
      <Drawer.Screen name="Notifications" component={CommonUserComponent} />
    </Drawer.Navigator>
  );
}

The error is undefined is not an object (evaluating 'props.naviagtion.closeDrawer')

Is there any way?? To make it work!!

Thank You !!

Satyam
  • 567
  • 1
  • 6
  • 20

1 Answers1

3

replace this

drawerContent={() => <DrawerNavigation {...props} />}

with this

 drawerContent={(props) => <DrawerNavigation {...props} />}
Mehran Khan
  • 3,616
  • 1
  • 13
  • 10