Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering tabs based on authentication and user roles #2699

Closed
dsah opened this issue Dec 11, 2017 · 1 comment
Closed

Rendering tabs based on authentication and user roles #2699

dsah opened this issue Dec 11, 2017 · 1 comment

Comments

@dsah
Copy link

dsah commented Dec 11, 2017

Version

Tell us which versions you are using:
react-native 0.50.3

  • react-native-router-flux v4.0.0-beta.22

Expected behaviour

Should render tabs depending on condition

Actual behaviour

There is no route defined for key0. Must be one of: "key2"

I have to implement tabs based on user roles after login. In some case, there may be 2 tabs and in other case, there may be 3 or more tabs. It wil be determined only after logged in.

Code:
renderTabs() {
const autho = []; //['admin', 'non-admin'];//this is dynamic array
return (
<Tabs lazy hideNavBar swipeEnabled={false} tabBarStyle={styles.tabBarStyle} showLabel={false} tabBarPosition={"bottom"}>
{auth0.map((accessRight, index) => {
if(accessRight==='admin')
return <Scene key="Admin" title="Admin" titleStyle={{ color: '#949494'}} titleDesc="Admin" component={Admin} icon={TabIcon('thermometer-full')} />;
if(accessRight==='non-admin)
return <Scene component={NonAdmin} key='non-admin' title="Non-Admin" titleDesc="Non-Admin" titleStyle={{ color: '#949494'}} icon={TabIcon('wrench')} headerMode="float"/>;
})}

);
}

Steps to reproduce

For non-obvious bugs, please fork this component, modify Example project to reproduce your issue and include link here.

  1. create tabs with some condition
  2. make it rerender using redux state change
  3. basically have no tabs when not logged in and after logged in have tabs based on condition
@as123456py
Copy link

Duplicate of #2349
hope to be useful to you

@Blapi Blapi closed this as completed Dec 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants