Javascript 反应本机+;世博会:等待时间和页面完成后,启动屏幕关闭
初始化模板“tabs”Expo项目后,React本机应用程序的启动例程如下所示:Javascript 反应本机+;世博会:等待时间和页面完成后,启动屏幕关闭,javascript,react-native,mobile,expo,splash-screen,Javascript,React Native,Mobile,Expo,Splash Screen,初始化模板“tabs”Expo项目后,React本机应用程序的启动例程如下所示: React.useEffect(() => { async function loadResourcesAndDataAsync() { try { SplashScreen.preventAutoHide(); // Load our initial navigation state setInitialNavigationState(await getIn
React.useEffect(() => {
async function loadResourcesAndDataAsync() {
try {
SplashScreen.preventAutoHide();
// Load our initial navigation state
setInitialNavigationState(await getInitialState());
// Load fonts
await Font.loadAsync({
...Ionicons.font,
'space-mono': require('./assets/fonts/SpaceMono-Regular.ttf'),
});
} catch (e) {
// We might want to provide this error information to an error reporting service
console.warn(e);
} finally {
setLoadingComplete(true);
SplashScreen.hide();
}
}
loadResourcesAndDataAsync();
}, []);
关于让“闪屏停留更长时间”,只需演示:
import { SplashScreen } from 'expo';
SplashScreen.preventAutoHide();
setTimeout(SplashScreen.hide, 5000);
问题是,如果仍在渲染背景/下一个视图,我希望启动屏幕保持不动,而不是简单地等待任意时间。例如,如果渲染时间需要0.2秒,并且我希望启动页面启动2秒,我希望启动页面在2秒时关闭。如果渲染时间需要2.8秒,我希望启动页面保持2.8秒。实现这一点的最佳方法是什么?尝试“componentDidMount”生命周期功能。
以下是想法: