How can I disable the physical device back button on Android with React-Native? I don't want to enable it for the user.
How do I disable the device back button on Android (react-native)?
8.1k Views Asked by Oskar Gusgård At
3
There are 3 best solutions below
1

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
}
0

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
Example
BackHandler.addEventListener('hardwareBackPress', function() {
return false;
});
Current open screen is tracked with a listener created when the application is launched, in app.js. Main component of the app creates a BackHandler listener, which responds to the device back button according to the currently open screen.
Main component:
App.js