我想在我的主屏幕加载到我的react-native应用程序之前显示非动画模式。基本上我想检查用户是否登录,如果没有登录用户在模态视图上显示登录屏幕。在主屏幕加载之前在react-native应用程序中显示模式
麻烦的是我的主屏幕出现在我的模态之前的一秒钟,而不是先出现模态。我是新的反应/ JavaScript的一般,我不知道如何解决这个问题。
我把我的登录支票componentWillLoad思维组件在屏幕上呈现前这会发生,但它似乎没有工作。
export default class MyClass extends Component {
state = {
modalVisible: false,
}
componentWillMount() {
// Check if a user is signed in
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
console.log("Signed in");
this.setState({modalVisible: false});
} else {
// No user is signed in.
console.log("Not signed in");
this.setState({modalVisible: true});
}
}.bind(this));
}
render() {
return (
<View>
<NavigatorIOS
initialRoute={{
component: Things,
title: 'MyScene',
}}
style={{flex: 1}}
/>
<Modal
animationType={"none"}
transparent={false}
visible={this.state.modalVisible}
onRequestClose={() => {alert("Modal has been closed.")}}
>
<Login />
</Modal>
</View>
);
}
}
我想,如果需要登录你应该使你的模态分量和正确的风格你的模态分量。我的意思是,如果(this.state.requireLogin)返回( ),否则返回null。 –