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

create if else in ROOT scene for choose tabs component #63

Open
pisangGoreng opened this issue Dec 16, 2017 · 0 comments
Open

create if else in ROOT scene for choose tabs component #63

pisangGoreng opened this issue Dec 16, 2017 · 0 comments

Comments

@pisangGoreng
Copy link

Hi

im have 2 costum tabs for user & admin. so after user login, the router flux will display tabs by catagory. im try to put if else in my root scene, but no work.

class RootRouter extends React.Component{
 
  constructor(props){
    super(props)
    this.state = {
      userId : '',
      userStatus:''
    }
  }

  componentDidMount () {
    AsyncStorage.getItem("status")
    .then(res => JSON.parse(res))
    .then(data => this.setState({
        userStatus : data
    }))
    .catch(err => console.log(err))    
}

  render () {
    return (
      <Router>
        <Scene key="root">
          <Scene key="login" component={Login} hideNavBar />
            {

              this.state.userStatus === 0 
              // IF ADMIN LOGIN
              ? (
                <Scene
                  key="main"
                  tabs={true}
                  tabBarPosition="bottom"
                  swipeEnabled
                  showLabel={false}
                  activeBackgroundColor="white"
                  inactiveBackgroundColor="#251a34"
                  tabBarStyle={{ backgroundColor: '#eee' }}
                >
                  <Scene key="tab_feed" title="Home" iconName="home" icon={TabIcon} component={Home} initial hideNavBar />
                </Scene>
              )
               // IF USER LOGIN
              : (
                <Scene
                  key="main"
                  tabs={true}
                  tabBarPosition="bottom"
                  swipeEnabled
                  showLabel={false}
                  activeBackgroundColor="white"
                  inactiveBackgroundColor="#251a34"
                  tabBarStyle={{ backgroundColor: '#eee' }}
                >
                  <Scene key="tab_feed" title="Home" iconName="home" icon={TabIcon} component={Home} initial hideNavBar />
                  <Scene key="tab_search" title="Search" iconName="search" icon={TabIcon} hideNavBar component={SearchEvent}
                  />
                </Scene> 
              )
            }
        </Scene>
      </Router>
    );
  }
  
}

export default RootRouter;

im try to refresh root screne with Actions.tab_feed({refresh: true}) , but still not work.
Please anyone idea to solve this? Thanks

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

1 participant