React-native-router-flux: Disable backButton on Modal

Created on 23 Oct 2016  路  3Comments  路  Source: aksonov/react-native-router-flux

Is it possible to disable the hardware backButton from popping when a modal is visible?

I'm using a load screen in a modal scene but users on Android can easily press on the back button which will make the load screen pop, even though the data hasn't even loaded yet..

Most helpful comment

import {BackAndroid} from 'react-native'

then in your component...

componentWillMount() {
    // Disable back button by just returning true instead of Action.pop()
    BackAndroid.addEventListener('hardwareBackPress', () => {return true});
}

All 3 comments

import {BackAndroid} from 'react-native'

then in your component...

componentWillMount() {
    // Disable back button by just returning true instead of Action.pop()
    BackAndroid.addEventListener('hardwareBackPress', () => {return true});
}

Why, not practical /reset/ this method

This is not working for me on RN 0.48, ReactNavigation 2.0 with

componentWillMount = () => BackHandler.addEventListener('hardwareBackPress', () => true);

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sylvainbaronnet picture sylvainbaronnet  路  3Comments

moaxaca picture moaxaca  路  3Comments

rafaelcorreiapoli picture rafaelcorreiapoli  路  3Comments

jgibbons picture jgibbons  路  3Comments

willmcclellan picture willmcclellan  路  3Comments