I just want to do:
In my "app.android.js" file (it is the App entry file), I do a check, when a user has not logined before, I will show the "loginScreen" as the home screen, otherwise show the "homeScreen".
However, I got a confusing issue: when user do login in "loginScreen", I push the "HomeScreen" to "this.props.navigator". Things seems OK, but once user touch the "hardware back" button, the "loginScreen" shows again~~~
Am i misusing it?
You can set overrideBackPress to true in your model config. You can then catch the event using setOnNavigatorEvent
@Ehesp thanks for your reply.
Actually, I misused it before, "this.props.navigator.resetTo" did a good job for me.
@Ehesp That solution does not work for me with the latset releases of RNN(tried 1.1.113 -> master-branch). If I set _overrideBackPress = true_, the click-event is overridden but it does not generate an event for the _setOnNavigatorEvent_. Am I missing something crucial in order to use this right? I'm in dire need for this to work properly
@em222iv You're not getting backPress event in your modal?
@guyca I'm not getting the event at all.
this.props.navigator.setOnNavigatorEvent((event) => {
event <= when clicking the "back button" in android i do not receive the "backPress" event when overrideBackPress = true
})
I've tried combining multiple versions of RNN with different versions of react-native (0.43 -> 0.46)
@em222iv This has nothing to do with react-native versions since RNN uses it's own navigation stack.
I've added the following to Modal.js in the example app and the event seems to work as expected
constructor(props) {
super(props);
this.props.navigator.setOnNavigatorEvent((event) => {
console.log(event);
})
}
Most helpful comment
You can set
overrideBackPressto true in your model config. You can then catch the event usingsetOnNavigatorEvent