How do I resolve this error? I've tried but still error ..
and this is my code root.js :
<DrawerLayoutAndroid
drawerWidth={250}
drawerPosition={DrawerLayoutAndroid.positions.Left}
renderNavigationView={() => navigationView}
ref={'DRAWER'}>
<Navigator
renderScene={this.renderScene}
initialRoute={{component: Home}}
ref={(nav) => { this.appNav = nav; }} />
</DrawerLayoutAndroid>
and this is my code in Home.js :
handleMenuPress() {
this.refs['DRAWER'].openDrawer();
}
<Header searchBar rounded>
<Item>
<Icon name="menu" onPress={this.handleMenuPress}/>
<Input placeholder="Cari Rumah Sakit" />
<Icon active name="search" />
</Item>
<Button transparent>
<Text>Search</Text>
</Button>
</Header>
Probably this
is not in scope of handleMenuPress. Try changing handleMenuPress to an arrow function.
handleMenuPress = () => {
this.refs['DRAWER'].openDrawer();
}
You should bind the method inside the constructor (it is the best way).
constructor(props){
super(props)
this.handleMenuPress = this.handleMenuPress.bind(this)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.