I have App \"Music App\" for tow users type \"Guest, a user registered\"
I have a bottom navigator for those, When Guest opens my app I want to render just 4 bottom tabs
You need to create dynamic routes, and one component that renders tabs based on whether the user is logged in or not. in Tabs.js
do the following.
const loginRoutes = {
Home: {
screen: Home,
navigationOptions: {
title: 'Home',
},
},
Browse: {
screen: Browse,
navigationOptions: {
title: 'Browse',
},
},
Search: {
screen: Search,
navigationOptions: {
title: 'Search',
},
},
Radio: {
screen: Radio,
navigationOptions: {
title: 'Radio',
},
},
Library: {
screen: Library,
navigationOptions: {
title: 'Library',
},
},
}
const noLoginRoutes = {
Home: {
screen: Home,
navigationOptions: {
title: 'Home',
},
},
Browse: {
screen: Browse,
navigationOptions: {
title: 'Browse',
},
},
Search: {
screen: Search,
navigationOptions: {
title: 'Search',
},
},
Radio: {
screen: Radio,
navigationOptions: {
title: 'Radio',
},
}
}
const mapStateToProps = state => {
return {
isLogin: state.user.isLogin,
};
};
const AppNav = ({ isLogin }) => {
const Container = createAppContainer(
createDrawerNavigator(
{
...drawerRoutes,
App: createStackNavigator(
{
...routes,
Tabs: createBottomTabNavigator(
isLogin ? loginRoutes : noLoginRoutes
),
},
routesConfig
),
},
drawerConfig
)
);
return ;
};
export default connect(mapStateToProps)(AppNav);
DEMO