React Native Router (React - Native - Router -flux)——在动作触发中有

React Native Router (react-native-router-flux) - more control in action triggering

本文关键字:React Native Router -flux      更新时间:2023-09-26

我们使用React Native Router来管理导航。我们路由器的渲染函数是这样的:

<Scene key="tabbar" tabs={true} hideNavBar={true} tabBarStyle={{position: 'absolute', top: 0, left: 0}}>
    <Scene key={TAB_1} component={Tab1Container} icon={TabIcon} title={TAB_1_TITLE} hideNavBar={true} />
    <Scene key={TAB_2}  component={Tab2Container} icon={TabIcon} title={TAB_2_TITLE} hideNavBar={true} />
    <Scene key={TAB_3}  component={Tab3Container} icon={TabIcon} title={TAB_3_TITLE}  hideNavBar={true} />
    <Scene key={TAB_4} component={Tab4Container} icon={TabIcon} title={TAB_4_TITLE}  hideNavBar={true} />
    <Scene key={TAB_5} component={Tab5Container} icon={TabIcon} title={TAB_5_TITLE}  hideNavBar={true} />
</Scene>

在我们的应用程序中,不允许立即从TAB_1跳到TAB_5。你必须从TAB_2到TAB_5。目前当我可以从开始跳转到结束

现在我找不到任何可能的东西,像一个函数,可以在动作被触发之前触发。

伪代码:

if(current_pressed_tab <= progress_tab){
  //head on to next tab
}
else{
  //make nothing
}

是否有我可以使用的功能或回调道具?

您需要跟踪您在Redux中导航的路线(我认为),并创建自定义Redux动作创建器,在触发导航之前运行您的检查伪代码