【发布时间】:2019-04-22 11:30:00
【问题描述】:
我的应用中有启动画面,5 秒后它会导航到另一个屏幕。
我想要的是启动画面应该只在第一次加载应用程序时显示,一旦用户退出应用程序并再次打开它,它就不应该显示启动画面。
这是我的代码
import React, { Component } from 'react';
import { View, ImageBackground, StyleSheet, BackHandler, Alert } from 'react-native';
import { Actions } from 'react-native-router-flux';
import colors from '../styles/colors';
class SplashScreen extends Component {
componentDidMount() {
// Start counting when the page is loaded
this.timeoutHandle = setTimeout(() => {
Actions.welcome()
}, 5000);
}
render() {
return (
<View style={styles.container}>
<ImageBackground
source={require('../assets/BSWH-splash.jpg')}
style={styles.backgroundImage}
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
backgroundImage: {
resizeMode: 'stretch',
flex: 1,
},
logoText: {
fontSize: 34,
color: colors.white,
margin: 10,
},
});
export default SplashScreen;
我使用 react-native-router-flux 进行导航
请帮助我如何在应用加载后隐藏启动画面。
【问题讨论】:
标签: react-native