[英]React Native Router Flux: navigate from main scene to child
I have few scenes. 我的场景很少。 one of scenes have few sub-scenes. 其中一个场景的子场景很少。 how can i navigate to one of sub-scenes from one of main scenes? 如何从一个主场景导航到其中一个子场景?
Example : 示例:
<Router createReducer={reducerCreate} getSceneStyle={getSceneStyle}>
<Scene key="root">
<Scene key="login" direction="vertical" component={Login} title="Login" hideTabBar hideNavBar />
<Scene key="tabbar" initial={show}>
<Scene key="main" tabs tabBarStyle={styles.tabBarStyle} tabBarSelectedItemStyle={styles.tabBarSelectedItemStyle} tabBarIconContainerStyle={styles.tabBarIconContainerStyle} >
<Scene key="courses" component={Courses} title="Courses" icon={IconCourses} navigationBarStyle={styles.navigationBarStyle} titleStyle={styles.titleStyle} initial />
<Scene key="register" component={Register} title="Register" icon={IconRegister} navigationBarStyle={styles.navigationBarStyle} titleStyle={styles.titleStyle} />
<Scene key="schedule" component={Schedule} title="Schedule" icon={IconSchedule} navigationBarStyle={styles.navigationBarStyle} titleStyle={styles.titleStyle} />
<Scene key="evaluation" component={Schedule} title="Evaluation" icon={IconEvaluation} navigationBarStyle={styles.navigationBarStyle} titleStyle={styles.titleStyle} />
<Scene key="profile"
component={Profile}
title="Profile"
icon={IconProfile}
navigationBarStyle={styles.navigationBarStyle}
titleStyle={styles.titleStyle}
onLeft={() => { Actions.login(); }}
leftTitle="Add Account"
onRight={() => { Actions.login({type: 'reset'}); }}
rightTitle="Logout"
rightButtonTextStyle={styles.ButtonTextStyle}
leftButtonTextStyle={styles.ButtonTextStyle}
leftButtonStyle={styles.leftButtonStyle} />
</Scene>
</Scene>
<Scene key="terms" component={Terms} />
<Scene key="details" component={Details} title="Details" navigationBarStyle={styles.navigationBarStyle} titleStyle={styles.titleStyle} backButtonTextStyle={styles.backButtonTextStyle} hideTabBar />
</Scene>
</Router>
I want to navigate from Details to Courses. 我想从详细信息导航到课程。 but courses is a Tab under another. 但课程是另一个课程。 how can i do that? 我怎样才能做到这一点?
I can navigate only to tabbar scene, not courses or register. 我只能导航到tabbar场景,而不是课程或注册。
I've found that you can switch to inner tabs if you navigate to the tabbar
first, eg: 我发现,如果你导航到你可以切换到内标签tabbar
第一,如:
<Button onPress={() => {
Actions.tabbar({type:ActionConst.RESET});
Actions.courses();
}} title="See Courses" />
The first scene transition resets the scene to your tab bar, and would by default show your initial
scene, the second transition then replaces your current scene due to how react-native-router-flux handles tab scene transitions. 第一个场景转换将场景重置为标签栏,默认情况下会显示您的initial
场景,然后由于react-native-router-flux处理标签场景转换的方式,第二个转换会替换当前场景。
I actually answered a very similar question here . 我在这里回答了一个非常相似的问题。 The problem is that from the context of login
you'd have access to Actions.tabbar
and it would then route you to either a nested scene with the initial
prop set to true, or the first nested scene in the stack. 问题是,从login
环境中您可以访问Actions.tabbar
,然后它会将您路由到initial
prop设置为true的嵌套场景,或者堆栈中的第一个嵌套场景。 To see an example of what I am talking about refer to the link I included in the first line of this answer. 要查看我正在谈论的内容的示例,请参阅本答案第一行中包含的链接。
Hope this helps! 希望这可以帮助! :) :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.