Reputation: 2047
SideMenu
is my custom drawer component and it has X
button in it.
When I press the X
button, I want the drawer to be closed.
How can I do this?
Upvotes: 0
Views: 443
Reputation: 5414
You can use this.props.navigation.closeDrawer() or this.props.navigation.toggleDrawer() for this.
<Button onPress={()=>this.props.navigation.closeDrawer()} />
or
<Button onPress={()=>this.props.navigation.toggleDrawer()} />
Upvotes: 2
Reputation: 581
You want to use toggleDrawer()
. Very basic example:
render() {
const { navigator } = this.props
return (
<Button
onPress={() => navigator.toggleDrawer({ side: 'right', animated: true })} />
)
}
Upvotes: 0