React-Native将标题从Navigator传递到NavigatorIOS
React-Native pass title from Navigator to NavigatorIOS
我一直在寻找这个问题的解决方案已经有一段时间了,现在找不到任何解决它的方法。
这是我想完成的事情。我正在创建一个带有登录屏幕的应用程序。登录屏幕不能有导航栏,但必须在登录后导航到一个导航栏,该导航栏带有从登录组件传递的自定义标题(用户名)。
当应用加载时,app组件将被标准的react Navigator组件加载,该组件依次呈现Login组件。当Login组件呈现时,它将检查以前的会话,并将用NavigatorIOS组件呈现主应用程序(Wrapper组件),该组件依次呈现另一个组件(List组件,未在下面的代码中显示)。
这可能吗?如果有,如何:)
我有以下代码:
// The first main component,
// this will be loaded from the AppRegistry
var App = React.createClass({
render() {
return (
<Navigator
initialRoute={{
component: Login
}}
renderScene={(route, navigator) => {
return React.createElement(route.component, { navigator });
}} />
)
}
});
// The login component that
// renders and handles all login processes.
var Login = React.createClass({
componentDidMount() {
// ... login logic ...
this.props.navigator.replace({
component: Wrapper,
// I want to pass a title here
});
},
render() {
return (
<Text>Login page</Text>
)
}
});
// When logged in, the NavigatorIOS component will be
// shown, here is where I want to title previously passed
// from the login component.
var Wrapper = React.createClass({
render() {
return (
<NavigatorIOS
initialRoute={{
component: List
title: // I want to fetch the title here
}} />
)
}
});
var Login = React.createClass({
componentDidMount() {
// ... login logic ...
this.props.navigator.replace({
component: Wrapper,
componentConfig : {
title : "My New Title"
}
// I want to pass a title here
});
},
render() {
return (
<Text>Login page</Text>
)
}
});
// When logged in, the NavigatorIOS component will be
// shown, here is where I want to title previously passed
// from the login component.
var Wrapper = React.createClass({
render() {
return (
<NavigatorIOS
initialRoute={{
component: List
title: this.props.title
}} />
)
}
});
相关文章:
- React Native NavigatorIOS
- ReactNative-在NavigatorIOS中使用推送时出错
- 新日期在使用日期时间选取器时返回 NA 值
- React Native:如何在不使用NavigatorIOS组件的情况下切换页面
- 如何提高NavigatorIOS的转换速度
- 错误:值<"= "NaN",错误:"text" "=“;Na
- React-Native将标题从Navigator传递到NavigatorIOS
- 选择“NA"第一个下拉框中的值不应该被禁用"NA"第二个下拉列表中的值
- React Native:不能读取property 'push'让NavigatorIOS和ES6绑定(
- java.lang.ClassCastException:jdk.nashorn.internal.objects.Na
- 如何获得'子控制器'React native中NavigatorIOS的引用
- React Native + Firebase 登录错误:Undefind 不是对象(评估 'this.props.na