Splash Screen and font in Expo

import { useEffect,useCallback } from 'react';
import { Stack } from 'expo-router';
import * as SplashScreen from 'expo-splash-screen';
import { useFonts } from 'expo-font';

then,

// Prevent the splash screen from auto-hiding before asset loading is complete.
SplashScreen.preventAutoHideAsync();

after this we need to export the layout, with


export default function RootLayout() {
  const [loaded, error] = useFonts({
    SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'),

    ...FontAwesome.font,
  });

we can use useState but use effect and useCallback can be more helpful

 useEffect(() => {
    if (error) throw error;
  }, [error]);
const onLayoutRootView= useCallback(async()=>{
    if(loaded){
        await SplashScreen.hideAsync();
    }
}, [loaded])
   if (!loaded) {
    return null;
  }