I'm getting one issue on android device back button. When I'm login to the app and go to home screen and from home screen, if I'm pressing device back button then it's redirected to me login screen again instead of the background.
Please help me how app go to background state when I'm pressing back button once app successful login in the app i.e. from home screen.
Here My code,
Login.js
//Click on login button call this method
home()
{
const { navigate } = this.props.navigation;
navigate('Home', { name: 'Home'});
}
Home.js:
constructor(props) {
super(props)
this.handleBackButtonClick = this.handleBackButtonClick.bind(this);
}
componentWillMount()
{
console.disableYellowBox = true;
console.log(this.props.navigation.state.routeName);
this.callapi();
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButtonClick);
}
handleBackButtonClick() {
if (this.props.navigation.state.routeName == 'Home') {
// this.props.navigation.goBack(null);
// BackHandler.exitApp()
this.props.navigation.dispatch(resetAction)
}
return false;
}