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

llgoer picture llgoer  路  3Comments

xnog picture xnog  路  3Comments

luco picture luco  路  3Comments

fgrs picture fgrs  路  3Comments

maphongba008 picture maphongba008  路  3Comments