I have been a lot of time searching and trying different stuff to disable going back once the "user" is logged in but it seams that NavigationActions does not work. This is the code:
import { NavigationActions } from 'react-navigation';
const actionToDispatch = NavigationActions.reset({
index: 0,
actions: [NavigationActions.navigate('DrawerNavigator')] // Array!
})
export default class LoginScreen extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<RkAvoidKeyboard
style={styles.screen}
onStartShouldSetResponder={ (e) => true}
onResponderRelease={ (e) => Keyboard.dismiss()}>
<View style={styles.content}>
<Button title="Complete Login" onPress={()=>this.props.navigation.dispatch(actionToDispatch)}/>
</View>
</RkAvoidKeyboard>
);
}
}
I shrinked a little bit the code. What happens is that the dispatch actions does not work. And also I get the error: undefined is not a function(evaluating '_reactNavigation.NavigationActions .......) so it does not even compile. I have the last version of React-navigation(2.12.0).