Wilson Fabian Pérez Sucuzhañay
PreguntaY si deseas hacer una pantalla custodia de SplashScreen como se hace, donde? Se puede poner animación?
Agustín Navarro Galdon
Para eso tendrías que usar esta dependencia. https://yarnpkg.com/package/react-native-splash-screen
Andres Roberto Coello Goyes
Si no quieres usar dependencias puedes envolver tu app en un context que te diga si esta en splash o no, la primero pantalla de tus rutas seria el splash por defecto y despues de X segudos cambias el estado de splash a false por ejemplo con eso se renderizara a la prixima ruta que podria ser tu home.
CONTEXT JS
import React, {createContext, useState, useEffect, Alert} from 'react'; export const UserContext = createContext(); const UserProvider = ({children}) => { const [isSplash, setIsSplash] = useState(false); useEffect(() => { if (!isSplash) { setTimeout(() => { setIsSplash(true); }, 11000); } }, [isSplash]); return ( <UserContext.Provider value={{ isSplash }}> {children} </UserContext.Provider> ); }; export default UserProvider;
NAVIGATION APP
<Stack.Navigator initialRouteName="SplashScrenn" screenOptions={({navigation}) => ({ headerStyle: {backgroundColor: colors.primary}, headerTitleAlign: 'center', headerTintColor: 'white', headerShown: false, headerLeft: () => ( <Icon size={27} style={{marginLeft: 10}} name="arrowleft" color="#fff" onPress={() => navigation.goBack()} /> ), })}> {!isSplash && <Stack.Screen name="SplashScrenn" component={SplashView} />} {!user && isSplash ? ( <> <Stack.Screen name="Login" component={LoginView} /> <Stack.Screen name="SignUp" options={{headerTitle: 'Registro'}} component={SignUpView} /> <Stack.Screen name="ForgotPass" component={ForgotPasswordView} /> <Stack.Screen name="Terminos" component={TerminosView} /> <Stack.Screen name="Privacidad" component={PrivacidadView} /> </> <Stack.Navigator />
Espero te ayude
