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

kirankalyan5 picture kirankalyan5  路  3Comments

basdvries picture basdvries  路  3Comments

VictorK1902 picture VictorK1902  路  3Comments

vinayr picture vinayr  路  3Comments

YouYII picture YouYII  路  3Comments