Q:

Preventing hardware backbutton to goback previous page

This question was asked before in this
However, componentDidMound() method prevents rendering page.
I have already changed BackAndroid to BackHandler but I couldn't manage it.
Also, what is ToastAndroid?
EDIT:
 I have used
componentWillUnmount(){
        BackHandler.removeEventListener('hardwareBackPress', function() { preventClose(); });
    }

componentDidMount() {
            BackHandler.addEventListener('hardwareBackPress', function() { preventClose(); });
      }
preventClose(){
    BackHandler.exitApp();
}

But it has bugs. When I move from my page to another page, if I press back button I immediately close the app. (I don't want this to happen. I just want to prevent the user from going back from my main screen, not other stack screens.)

A:

That should be very basic. In you activity you just need to override the onBackPressed() method.
@Override
public void onBackPressed() {
    // super.onBackPressed(); <- this line of code will make you go back to the previous "page"

    // now you can insert additional code, if you want to do it.
}

As long as you don't add super.onBackPressed(); this will prevent from going back to previous page.

A:

You can simply override onBackPressed() and comment super method. 
@Override
public void onBackPressed() {

    // super.onBackPressed(); -> Just comment that line this will prevent device back button action.
}

Thanks.

