我可以在React-native中进行类似从React的延迟加载吗?当我单击某个按钮时,我需要等待渲染另一个屏幕不完整,然后再转到该屏幕。现在,单击后,我将看到默认的背景色,并且将显示另一页面。我可以做类似懒惰的事情,还是可以将默认backgroundImage设置为整个App?
const HomeScreen = ({ navigation: { navigate } }) => {
const [dateLoaded, setDataLoaded] = useState(false)
if (!dateLoaded) {
return <AppLoading
startAsync={fetchFonts}
onFinish={() => setDataLoaded(true)}
/>
}
return (
<View style={styles.container} >
<ImageBackground source={require('../../../assets/background.png')} style={styles.backgroundImage}>
<View horizontal={true} style={styles.formLogin}>
<TouchableOpacity onPress={() => { navigate("LoginForm") }}>
<View style={styles.loginButton} >
<Text style={styles.textButton}>Вход</Text>
</View>
</TouchableOpacity>
<TouchableOpacity onPress={() => { navigate("Visits") }}>
<View style={styles.registrationButton} >
<Text style={styles.textButton}>Регистрация</Text>
</View>
</TouchableOpacity>
</View>
</ImageBackground>
</View>
)
};