Actions.popTo(tabBarKey) 破坏应用程序。 - React Native Router Flux

Actions.popTo(tabBarKey) breaks app. - React Native Router Flux

在我当前的应用程序中,用户填写了一个由不同场景组成的表单,一旦到达表单的最后一个场景并且提交成功,我想 "popTo" 回到初始场景。然而,这个初始场景在 <Tabs> 标签内,我认为这就是它破坏我的应用程序的原因。

这是我的 Router.js:

const RouterComponent = () => {
return (
<Router>
  <Scene key="root">
    <Scene key="spinnerBucket">
      <Scene
        key="spinner"
        component={SpinnerComponent}
        initial
        hideNavBar
        panHandlers={null}
      />
    </Scene>

    <Scene key="authBucket">
      <Scene
        key="login"
        component={LoginComponent}
        initial
        hideNavBar
        panHandlers={null}
      />
    </Scene>


    <Tabs
      lazy
      headerMode="none"
      key="tabBar"
      navBar={NavigationComponent}
      tabBarPosition={'bottom'}
     >
      <Scene
        key="home"
        initial
        component={HomeComponent}
        panHandlers={null}
        />

      <Scene
        key="profile"
        component={ProfileComponent}
        panHandlers={null}
        />

      <Scene
        key="activeJobs"
        component={ActiveJobsComponent}
        panHandlers={null}
        />

      <Scene
        key="favorites"
        component={FavoritesComponent}
        panHandlers={null}
        />

      <Scene
        key="inbox"
        component={InboxComponent}
        panHandlers={null}
        />
    </Tabs>


    <Scene
      key="displayOffer"
      hideNavBar
      component={DisplayOffersComponent}
      panHandlers={null}
    />

    <Scene
      key="selectJob"
      hideNavBar
      component={SelectJobComponent}
      panHandlers={null}
    />

    <Scene
      key="createJob"
      hideNavBar
      component={JobScheduleComponent}
      panHandlers={null}
    />

    <Scene
      key="define_title"
      hideNavBar
      component={DefineTitleComponent}
      panHandlers={null}
    />

    <Scene
      key="requirements"
      hideNavBar
      component={RequirementsComponent}
      panHandlers={null}
    />

    <Scene
      key="quantity_question"
      hideNavBar
      component={QuantityQuestionComponent}
      panHandlers={null}
    />

    <Scene
      key="add_comments"
      hideNavBar
      component={AddCommentsComponent}
      panHandlers={null}
    />

    <Scene
      key="multiple_choice"
      hideNavBar
      component={MultipleChoiceComponent}
      panHandlers={null}
    />

    <Scene
      key="infoMissing"
      hideNavBar
      component={InfoMissingComponent}
      panHandlers={null}
    />

    <Scene
      key="user_description"
      hideNavBar
      component={JobDetailsComponent}
      panHandlers={null}
    />

    <Scene
      key="jobDetailsPhotos"
      hideNavBar
      component={JobTagsAndPhotosComponent}
      panHandlers={null}
    />

    <Scene
      key="googlePlaces"
      hideNavBar
      component={GooglePlacesComponent}
      panHandlers={null}
    />

    <Scene
      key="chat"
      hideNavBar
      component={ChatComponent}
      panHandlers={null}
    />

    <Scene
      key="publicProfile"
      hideNavBar
      component={PublicProfileComponent}
      panHandlers={null}
    />
  </Scene>
</Router>
);
};

当我在

中时,问题就出现了
    <Scene
      key="jobDetailsPhotos"
      hideNavBar
      component={JobTagsAndPhotosComponent}
      panHandlers={null}
    />

我打电话给 Actions.popTo("tabBar");。该应用程序只是冻结和中断。我的问题是:是我的场景结构有问题还是有特殊的方法可以弹出标签页?

我的目标是回到<Scene key="home"/>

对于 popTo,您应该只使用 'leaf' 个场景键。

Actions.popTo 工作正常,只需像这样使用它:

Actions.popTo("sceneName");

版本:

"react": "16.0.0",
"react-native": "^0.51.0",
"react-native-router-flux": "^4.0.0-beta.28",

您可以通过在主场景之前的启动中执行 Actions.theNameForYourScene 将您的场景明确添加到堆栈中,以便能够在之后弹出它。不推荐,但有效。