Just implemented a login page.
刚刚实现了登录页面。
After user click the login button. How to navigate to my home page module?
用户单击登录按钮后。如何导航到我的主页模块?
The code should look like this:
代码应该如下所示:
login module:
class MyClient extends Component{
render() {
return (
<View style={styles.container}>
<TouchableHighlight style={styles.button}
onPress={this.login.bind(this)}>
</TouchableHighlight>
</View>
);
}
login() {
//How to switch to home view here?
}
}
module.exports = MyClient;
Home module:
class Home extends Component{
render() {
return (
<View>
<Text>This is home page</Text>
</View>
);
}
}
module.experts = Home;
I don't want to use navigator this component cuz' I think home module & login module should not be sort of parent&child relationship.
我不想使用导航器这个组件因为'我认为家庭模块和登录模块不应该是父子关系。
Is there a way to switch between these two page?
有没有办法在这两个页面之间切换?
1 个解决方案
#1
You have to use the navigator. You could try to use "replace" instead of "push". With this you can achieve an instant navigation between Components.
你必须使用导航器。您可以尝试使用“替换”而不是“推送”。有了这个,您可以实现组件之间的即时导航。
this.props.navigator.replace({
title: 'Home', component: Home
});
And just in case you want to hide the navigation bar there is the "navigationBarHidden" property of NavigatorIOS component.
如果您想要隐藏导航栏,则NavigatorIOS组件的“navigationBarHidden”属性。
<NavigatorIOS navigationBarHidden = 'true' />
#1
You have to use the navigator. You could try to use "replace" instead of "push". With this you can achieve an instant navigation between Components.
你必须使用导航器。您可以尝试使用“替换”而不是“推送”。有了这个,您可以实现组件之间的即时导航。
this.props.navigator.replace({
title: 'Home', component: Home
});
And just in case you want to hide the navigation bar there is the "navigationBarHidden" property of NavigatorIOS component.
如果您想要隐藏导航栏,则NavigatorIOS组件的“navigationBarHidden”属性。
<NavigatorIOS navigationBarHidden = 'true' />