I have used Font.loadAsync many times but for some reason, I keep getting errors while trying to use it this time.

pastebin

import React from "react";

推荐答案

在我的最新项目中,我也在努力学习Font.loadAsync.我决定改用expo-font模块.您可以在App中初始化此模块.它将加载所有屏幕的字体.

以下是一个示例:

import React from "react";
...

import { useFonts } from "expo-font"; //need to load fonts asynchronously

...

const App = () => {

  const [loaded] = useFonts({// function for expo-font 
    RobotoBlack: FONTS.Roboto-Black.ttf,
    RobotoBold: FONTS.Roboto-Bold.ttf,
    RobotoRegular:FONTS.RobotoRegular.ttf,
  });
  if (!loaded) {
    return null;
  }

...

React-native相关问答推荐

react-native useEffect / useFocusEffect / useCallback 没有正确更新

如何在 react-navigation v6 中更改标题高度

React Native - Expo:fontFamily 'SimpleLineIcons' 不是系统字体,尚未通过 Font.loadAsync 加载

我可以在状态内有一个函数来响应吗?

react-native 中的layout-only view removal优化是什么?

使用 AsyncStorage 如何以及在何处保存整个 redux 存储

React Native Card Carousel 视图?

如何在 mac 上卸载 react-native-cli?

如何实时从 react-native-camera 获取帧

命令失败:gradlew.bat installDebug error whenever installing dependencies like navigation, firebase, icons etc in React-Native

如何在 React Native 中获取 TextInput 相对于其父级或屏幕的光标位置

如何使用 Typescript 在无状态组件上设置 navigationOptions

我将如何根据百分比为按钮的宽度设置动画,并且它的背景 colored颜色 也是如此?

Android 是否支持 React Native 的 LayoutAnimation?

如何在 React Native 中更改 textInput 占位符的字体系列

如何设置样式属性以填充剩余空间?

如何从react-native应用程序打开外部应用程序?

如何在 react-native 中设置 Alert 元素的样式?

将现有的 React Native 项目转换为 Expo

使用 TouchableWithoutFeedback react-native onPress 不起作用