Why navigation.closeDrawer is not a function?

Try this

import { DrawerActions } from 'react-navigation';

this.props.navigation.dispatch(DrawerActions.closeDrawer());
this.props.navigation.dispatch(DrawerActions.openDrawer());

You are using both StackNavigator and DrawrNavigator so that the way to use them is different a little bit.

Keep in mind we have two version for react-navigation (v1 and v2) for now so that you should read the documentation carefully.

Please try using this:

  • Close drawer

    this.props.navigation.navigate('DrawerClose'); // for version 1 this.props.navigation.openDrawer(); // for version 2

  • Open drawer:

    this.props.navigation.navigate('DrawerOpen'); // for version 1 this.props.navigation.closeDrawer(); // for version 2

Be careful for reference any bugs fix for this libraries on the internet which you have to know which version is using in.

  • Note that the order of nesting - if the stack navigator is not inside of the drawer, it will not have the openDrawer function.

    I guess it will work for you in this case.

Cheer!