'React Native & Expo, how to control the splash screen?
I'm using the built in splash screen in expo that you add in app.json for a simple test app. However I noticed that my start screen flashes in default mode 1 millisecond before showing the assets that I've added with AsyncStorage.
I've tried using splash-screen package from expo
but I found it a bit confusing. Is there a fairly easy way to add in my App.js this logic :
Show a splash screen and when all assets are loaded, load this setup (with my contexts and screens), or just increase loading time of the build in splash screen from expo (because I assume it loads over the assets being fetched?).
const App = () => {
const [selectedTheme, setSelectedTheme] = useState(themes.light)
const changeTheme = async () =>{
try {
const theme = await AsyncStorage.getItem("MyTheme")
if (theme === "dark"){
setSelectedTheme(themes.nightSky)}
else if (theme === "light") {
setSelectedTheme(themes.arctic)
}
} catch (err) {alert(err)}
}
useEffect(()=> {
changeTheme()
},[])
return (
<ThemeContext.Provider value={{selectedTheme, changeTheme}}>
<NavigationContainer>
<Stack.Navigator screenOptions={{headerShown:false, presentation: 'modal'}}>
<Stack.Screen name="Home" component={home}/>
</Stack.Navigator>
</NavigationContainer>
</ThemeContext.Provider>
);
};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
