I would like after Login (Welcome) the user to navigate to Home. I reset the history so the user cannot go back like this:
const actionToDispatch = Navigatio
For anyone who is looking for React Navigation 3.x and 4.x solution
import {NavigationActions, StackActions} from 'react-navigation';
const resetAction = StackActions.reset({
index: 0,
actions: [NavigationActions.navigate({routeName: 'Home'})],
key: null,
});
this.props.navigation.dispatch(resetAction);
React Navigation move the reset method to StackActions since 3.x
I found the solution here: https://github.com/react-community/react-navigation/pull/789.
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'Welcome' }),
],
key: null
});
this.props.navigation.dispatch(resetAction);
key: null is the important part.