【问题标题】:how to implement dynamic tabs use react native router flux?如何实现动态选项卡使用反应原生路由器通量?
【发布时间】:2017-01-16 04:36:08
【问题描述】:
  • react-native 0.38.1
  • react-native-router-flux 3.37.0

    我想实现基于身份验证的动态选项卡,当用户登录时,显示主页和个人资料选项卡,否则只显示主页选项卡

    我使用Switch,但不起作用。

     <Scene key="tabbar"
       tabs
       type={ActionConst.RESET}
       initial
       hideNavBar
       tabBarStyle={ styles.tabBar }
       pressOpacity={1}
       default="main">
    
         <Scene key="main"
             title="Home"
             type="switch"
             icon={TabHomeIcon}
             hideNavBar
             component={Main}
             initial/>
    
        <Scene key="profile"
            title="Profile"
            type="switch"
            icon={TabMeIcon}
            hideNavBar
            component={Profile}/>
    </Scene>
    

【问题讨论】:

  • 我也有同样的问题。 @圆顶。你找到解决办法了吗?

标签: react-native-router-flux


【解决方案1】:

这是文档中的示例:

<Scene
    key="root"
    component={connect(state=>({profile:state.profile}))(Switch)}
    tabs={true}
    unmountScenes
    selector={props=>props.profile.sessionID ? "main" : "signUp"}
    >
    <Scene key="signUp" component={SignUp}/>
    <Scene key="main" component={Main}>
</Scene>

【讨论】:

  • 虽然欢迎使用此代码 sn-p,并且可能会提供一些帮助,但它会是 greatly improved if it included an explanation of howwhy 这解决了问题。请记住,您正在为将来的读者回答问题,而不仅仅是现在提问的人!请edit您的答案添加解释,并说明适用的限制和假设。
猜你喜欢
  • 2017-03-31
  • 1970-01-01
  • 1970-01-01
  • 2021-11-08
  • 2022-01-19
  • 1970-01-01
  • 1970-01-01
  • 2023-04-11
  • 1970-01-01
相关资源
最近更新 更多