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



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

这是我的路由器.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 使用"叶子"场景键。

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,将场景显式添加到堆栈中,以便能够在之后弹出它。不推荐,但它有效。

相关内容

  • 没有找到相关文章