我得到了这个错误的多重时间
您开始加载字体"Poppins_400Regular",但在完成加载之前使用它。在使用字体之前,您需要等待Font.loadAsync完成。
运行代码时
发布于 2021-12-30 13:45:55
在应用程序入口点,通常是App.jsx,您可以在加载应用程序的字体时呈现null或加载状态,然后在loadAsync完成后呈现应用程序,大致如下:
// App.jsx, or whatever your entry point is
const App = () => {
const [fontLoaded, setFontLoaded] = React.useState(false)
React.useEffect(() => {
Font.loadAsync({
"Poppins_400Regular": require("../path/to/your/font"),
})
.then(() => {
setFontLoaded(true)
})
}, [])
if (!fontLoaded) return null
return (
// All of your normal app ui
)
}https://stackoverflow.com/questions/70532368
复制相似问题