【发布时间】:2018-10-25 07:34:15
【问题描述】:
如果我的导航堆栈是空的,我想最小化安卓设备上的应用程序。目前它什么也没做。我正在使用下面的代码来处理后退按钮。
componentDidMount () {
BackHandler.addEventListener('hardwareBackPress', () => this.backAndroid()) // Listen for the hardware back button on Android to be pressed
}
componentWillUnmount () {
BackHandler.removeEventListener('hardwareBackPress', () => this.backAndroid()) // Remove listener
}
backAndroid () {
Actions.pop() // Return to previous screen
return true // Needed so BackHandler knows that you are overriding the default action and that it should not close the app
}
【问题讨论】:
标签: react-native expo react-native-router-flux