Menu

Three promises hold our splash screen, a font error counts as loaded, and the session is deliberately not one of them
📰

Three promises hold our splash screen, a font error counts as loaded, and the session is deliberately not one of them

DEV Community: reactnative·Daniel Pertu·11 days ago
#X9CacO2V
#devtoreactnative#devto#dev#gate#bundled
Reading 0:00
15s threshold

Cold start is the one piece of an app that every single user experiences, in full, before they experience anything else. Munchable's version of it is five lines, and the interesting thing about those five lines is not what they wait for. It is what they are not allowed to do.

const [ fontsLoaded , fontError ] = useFonts ( fontMap ); const hydrated = useProfile (( s ) => s . hydrated ); const taxonomyHydrated = useTaxonomy (( s ) => s . hydrated ); const ready = ( fontsLoaded || !! fontError ) && hydrated && taxonomyHydrated ;

if ( ! ready ) return null ;

Enter fullscreen mode

Exit fullscreen mode

With SplashScreen.preventAutoHideAsync() called at module scope and hideAsync() fired in an effect once ready turns true, the return null is never visible. The splash stays up, and the first thing drawn is a finished screen.

The rule I hold myself to is that every one of those three conditions has to be a promise that cannot reject. Not "should not". Cannot.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.