Mohamed Amine Zaoui
Mohamed Amine Zaoui

Reputation: 15

error with a drawer navigation in react-native :undefined is not an object (evaluating '_this.props.navigation.openDrawer()')

I had set up a navigator drawer that works perfectly, but since this morning I have this error. I do not know where it came from. Because I did not make any changes on the drawer. I can't use the function close drawer.


   <Left style={{flex :1, flexDirection: 'row'}}>
       <Icon 
              onPress={() => this.props.navigation.openDrawer()} name="menu"
              tyle={{color: 'black', marginRight: 15,}} />
   </Left>

the error is :

undefined is not an object (evaluating '_this.props.navigation.openDrawer()')

Upvotes: 1

Views: 926

Answers (1)

Shankar S Bavan
Shankar S Bavan

Reputation: 962

You can Try this

import { DrawerActions } from 'react-navigation';

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

Upvotes: 2

Related Questions