React native 在React Native中添加一次欢迎屏幕
我已经在我的应用程序中创建了一个欢迎屏幕,我想在第一次启动时显示它。现在我第一次使用AsyncStorage存储值,并使用该值呈现主页或欢迎页面。现在是这样的:React native 在React Native中添加一次欢迎屏幕,react-native,react-navigation,React Native,React Navigation,我已经在我的应用程序中创建了一个欢迎屏幕,我想在第一次启动时显示它。现在我第一次使用AsyncStorage存储值,并使用该值呈现主页或欢迎页面。现在是这样的: componentDidMount(){ AsyncStorage.getItem('first_time')。然后((value)=>{ this.setState({showRealApp:!value,loading:false}); }); if(this.state.showRealApp==true){ 返回( 欢迎页面
componentDidMount(){
AsyncStorage.getItem('first_time')。然后((value)=>{
this.setState({showRealApp:!value,loading:false});
});
if(this.state.showRealApp==true){
返回(
欢迎页面
)}
否则{
返回(
)
}
}
您没有正确导航到主页,请使用导航。导航(“主页”)
class FirstTimePage扩展React.Component{
componentDidMount(){
AsyncStorage.getItem('first_time')。然后((value)=>{
this.setState({showRealApp:!value,loading:false});
});
}
render(){
const{navigation}=this.props;
if(this.state.showRealApp==true){
返回(
欢迎页面
)
}
否则{
导航。导航(“主页”);
}
}
}
class FirstTimePage extends React.Component{
componentDidMount() {
AsyncStorage.getItem('first_time').then((value) => {
this.setState({ showRealApp: !value, loading: false });
});
}
render(){
const {navigation} = this.props;
if (this.state.showRealApp === true) {
return (
<View>
<Text>Welcome Page</Text>
</View>
)
}
else {
navigation.navigate('Home');
}
}
}