I'm looking for a way to conditionally disable the swipe to go back gesture in react native iOS. I'm using the react-navigation
library to control navigation. For Android, I am able to do it using BackHandler. Is it possible to do something similar in iOS?
componentDidMount() {
BackHandler.addEventListener("hardwareBackPress", this.handleBackButton);
}
handleBackButton = () => {
if (this.props.creating) {
return true; // Disables the back button in Android
}
};
componentWillUnmount() {
BackHandler.removeEventListener(
"hardwareBackPress",
this.handleBackButton
);
}
Yes, there is an option to disable gestures:
screen: ExampleView
navigationOptions: {
gesturesEnabled: false,
},
Check for more details here: https://github.com/react-navigation/react-navigation/issues/1063
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With