Reputation: 1657
I am using react-native-drawer-layout
for navigation drawer.
<DrawerLayoutAndroid
drawerWidth={100}
ref={'Drawer'}
drawerPosition={DrawerLayoutAndroid.positions.Right}
renderNavigationView={() => NavigationView}
/>
When i try to close the drawer
total app is getting closed.
Could anybody let me know how to close the drawer with hardware(android) button?
Upvotes: 1
Views: 895
Reputation: 833
I never user DrawerLayoutAndroid but according to the React Native Docs it has method "closeDrawer()" that is supposed to close it... by using BackHandler you should add an event listener to the component containing the drawer layout, add this:
componentDidMount(){
BackHandler.addEventListener('hardwareBackPress', ()=>{
this.refs.Drawer.closerDrawer();
return true;
});
}
Upvotes: 1