React-native-router-flux: Remove Back Button For Android

Created on 15 Sep 2016  路  7Comments  路  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using:

  • react-native-router-flux v3.35.0
  • react-native v0.34.0-rc.0

Since android already has a back button, is it possible to completely remove the leftButton (back etc)?
I've tried renderBackButton={null} and hideBackImage={false} and they didn't work.

Most helpful comment

@AndrewHenderson hey!

i've hacked this annoying behavior like this:

<Scene key='myScreenWithNoBackButton' component={MyScreenWithNoBackButton} hideBackImage onBack={() => null}/>

hope it helps you 馃槂

have a good one!

All 7 comments

I was going to reply here and ask how you solved this issue, then i realized you had tried hideBackImage={false} where it SHOULD be hideBackImage={true} or simply: hideBackImage.

<Scene key='myScreenWithNoBackButton' component={MyScreenWithNoBackButton} hideBackImage />

@markrickert @alexcurtis I am using hideBackImage. While the image does not appear, if I press the spot where the back button would be, it still navigates back. 馃槙

Tell us which versions you are using:

  • react-native-router-flux v3.36.0
  • react-native v0.37.0

@AndrewHenderson hey!

i've hacked this annoying behavior like this:

<Scene key='myScreenWithNoBackButton' component={MyScreenWithNoBackButton} hideBackImage onBack={() => null}/>

hope it helps you 馃槂

have a good one!

import { BackAndroid } from 'react-native';

componentWillMount() {
BackAndroid.addEventListener('hardwareBackPress', () => {return true});
}

Use:

import { ... BackAndroid } from 'react-native';

componentDidMount() {
  BackAndroid.addEventListener('hardwareBackPress', () => { return true });
  ...
}
componentWillMount() {
  BackAndroid.removeEventListener('hardwareBackPress', () => { return true });
  ...
}

@vnhnhm A quite note to say that your event handler won't be removed in the code you posted. You're creating a new instance of a closure and passing it to removeEventListener.

We use:

constructor(props) {
  ....
  this.handleBackAndroid = () => true;
}

componentDidMount() {
  BackAndroid.addEventListener('hardwareBackPress', this.handleBackAndroid);
  ...
}
componentWillMount() {
  BackAndroid.removeEventListener('hardwareBackPress', this.handleBackAndroid);
  ...
}

Thanks @benvium, I haven't noticed it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kirankalyan5 picture kirankalyan5  路  3Comments

jgibbons picture jgibbons  路  3Comments

YouYII picture YouYII  路  3Comments

sarovin picture sarovin  路  3Comments

booboothefool picture booboothefool  路  3Comments