App.js剪断
render() {
if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
return (
<AppLoading
startAsync={this._loadResourcesAsync}
onError={this._handleLoadingError}
onFinish={this._handleFinishLoading}
/>
);
} else if (!this.state.isAuthenticated) {
return (
<Router>
<Scene key="root">
<Scene key="signIn"
component={SignIn}
title="Scarlet"
initial
/>
<Scene
key="signUp"
component={SignUp}
title="Gray"
/>
</Scene>
</Router>
)
} else {
return (
<AppNavigator/>
)
}
}
我想这样做的是通过isAuthenticated状态变量进入签到组件作为道具。然后,在成功调用我的认证服务后,登入回调里面我可以更新道具,背App.js而不是登入/注册所呈现的AppNavigator部分将被渲染。
我无法找到文件或之间如何传递这些价值的例子。
Passing props in react-native-flux-router
我发现这上面的例子,但我通过道具分配给handleClick的事实感到困惑
How to pass values to other component in React-Native-Router-Flux?
我也发现了这个例子,这似乎很有前途,但我不知道在哪里的Actions.key {}道具去。这个人似乎有它分配给onPress。
我的问题是,我没有使用点击这里的场景之间进行导航。我使用的是内登入和注册的Action对象。
对不起,我知道这是散漫的,但我希望有人将有见过这个。
如果我读这个权利,你要调用一个Action,并传递一个变量作为属性。 Actions.signIn({ isAuthenticated: true });
然后你在isAuthenticated
场景中使用此signIn
属性与this.props.isAuthenticated
。
或者,如果你想通过一个函数作为一个属性:
let myFunction = () => {
//do some magic here
};
Actions.signIn({ doMagic: myFunction });
然后在你的signIn
你打电话this.props.doMagic();
和myFunction
被调用。