I'm using a stack navigator and on
<HeaderBackButton onPress={_ => navigation.goBack(null)}
I want to destroy current screen, I've seen other replacements like using .replace instead of .navigate but I want to do such thing on .goBack.
I'm using a stack navigator and on
<HeaderBackButton onPress={_ => navigation.goBack(null)}
I want to destroy current screen, I've seen other replacements like using .replace instead of .navigate but I want to do such thing on .goBack.
You can try this way:
componentDidMount() {
this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.handleBackPress);
}
componentWillUnmount() {
this.backHandler.remove()
}
handleBackPress = () => {
this.goBack(); // works best when the goBack is async
return true;
}