We are using React Navigation for our React Native application and showing side bar. Everything working fine, But, close Drawer is not working.
Actually, I have to close Drawer while user tap on Android device back button.
So, That I am calling navigation.closeDrawer();
inside the back button handler method.
backButtonTap = () => {
const { navigation } = this.props;
navigation.closeDrawer();
DeviceEventEmitter.emit('NavigatedToNewRoute', {
route: 'screen1'
});
navigation.navigate('screen1');
}
But, While we tried to close by device back button side drawer not closing.
OpenDrawer
method working fine.
And I have number of screens in my sidebar. So, In each class do I need to call this closeDrawer method or any one global class can we call it? I just need to close if the drawer opens, And if the user tap on the device back button, I have to close this drawer.
Any suggestions?