Since expo-app-loading is being deprecated, can the readme change to expo-splash-screen
obayit opened this issue · 3 comments
obayit commented
As said in the title, the expo-app-loading
is being deprecated, and the example in the readme page would be better if it was using the new expo-splash-screen
.
dodyeid commented
Seconding this! How do I use this package without using expo-app-loading
?
dodyeid commented
I found a dirty fix for this , but not too dirty since I don't get warnings or errors.
Instead of using expo-app-loading, I do this:
if (!fontsLoaded) { return null; }
Working like a charm in latest SDK. Im not an expert, so if someone sees an issue with this, lmk!
corysimmons commented
Agreed, it'd be nicer to just copy/paste something from this README, but for posterity, https://docs.expo.dev/versions/latest/sdk/font/#usage tells us how.
import { Inter_900Black, useFonts } from '@expo-google-fonts/inter'
import * as SplashScreen from 'expo-splash-screen'
import { useCallback } from 'react'
import { Text, View } from 'react-native'
SplashScreen.preventAutoHideAsync()
export default function IndexScreen() {
const [fontsLoaded] = useFonts({
Inter_900Black,
})
const onLayoutRootView = useCallback(async () => {
if (fontsLoaded) {
await SplashScreen.hideAsync()
}
}, [fontsLoaded])
if (!fontsLoaded) {
return null
}
return (
<View style={{ flex: 1 }} onLayout={onLayoutRootView}>
<Text>Hi</Text>
</View>
)
}