Skip to content

Instantly share code, notes, and snippets.

@shubhnik
Last active November 10, 2017 12:17
Show Gist options
  • Save shubhnik/cb8129472421632cf27beefd304d6fdc to your computer and use it in GitHub Desktop.
Save shubhnik/cb8129472421632cf27beefd304d6fdc to your computer and use it in GitHub Desktop.
Here we are passing stateForLoggedIn if the user is logged in or stateForLoggedOut if the user is logged out.
// our navigationReducer which will feed AppNavigator with navigation state ---> https://gist.github.com/shubhnik/9f7bafd3145e66434705cd1e995d1356
// Don't forget to check the complete code here ---> https://github.com/shubhnik/redux-react-navigation/tree/authFlow
const AppNavigator = StackNavigator({
login: {
screen: Login
},
screen1: {
screen: Screen1
},
screen2: {
screen: Screen2
}
});
class AppNavigation extends Component {
render() {
const { navigationState, dispatch, isLoggedIn } = this.props;
const state = isLoggedIn
? navigationState.stateForLoggedIn
: navigationState.stateForLoggedOut;
return (
<NavigationStack
navigation={addNavigationHelpers({ dispatch, state})}
/>
);
}
}
const mapStateToProps = state => {
return {
isLoggedIn: state.LoginReducer.isLoggedIn,
navigationState: state.NavigationReducer
};
};
export default connect(mapStateToProps)(AppNavigation);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment