Skip to content

Instantly share code, notes, and snippets.

@aloukissas aloukissas/router.js
Created Jan 14, 2019

Embed
What would you like to do?
import React from "react";
import {
createStackNavigator,
createBottomTabNavigator,
createSwitchNavigator
} from "react-navigation";
import Signup from "./screens/Signup";
import Login from "./screens/Login";
import Home from "./screens/Home";
import Profile from "./screens/Profile";
export const Unauthenticated = createStackNavigator({
Signup: {
screen: Signup,
navigationOptions: {
title: "Sign up"
}
},
Login: {
screen: Login,
navigationOptions: {
title: "Login"
}
}
});
export const Authenticated = createBottomTabNavigator({
Home: {
screen: Home,
navigationOptions: {
title: "Home"
}
},
Profile: {
screen: Profile,
navigationOptions: {
title: "Profile"
}
}
});
export const createRootNavigator = isAuthenticated => {
return createSwitchNavigator(
{
Authenticated: {
screen: Authenticated
},
Unauthenticated: {
screen: Unauthenticated
}
},
{
initialRouteName: isAuthenticated ? "Authenticated" : "Unauthenticated"
}
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.