How can I disable the physical device back button on Android with React-Native? I don't want to enable it for the user.
There is no out of the box support from React Native Navigation as of today on v2. However, you could use BackHandler
from React native itself. To handle it and return false to disable it.
Doc on BackHandler
BackHandler.addEventListener('hardwareBackPress', function() {
return false;
});
In activity you can override the onBackPressed()
and comment the calling to super class.
@Override
public void onBackPressed() {
// super.onBackPressed(); comment this line to disable back button press
}
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