React Native (Expo) says font has not been loaded with Font.loadAsync (but I think it has)

364 Views Asked by At

This is a snippet of my code:

export default class HomeScreen extends React.Component {
  state = {
    fontLoaded: false,
  };

  async componentDidMount() {
    await Font.loadAsync({
      'Ubuntu-Regular': require('../assets/fonts/Ubuntu-Regular.ttf'),
      'Ubuntu-Bold': require('../assets/fonts/Ubuntu-Bold.ttf'),
    });

    this.setState({ fontLoaded: true });
  }

  render() {
  ...

Yet I continue to get the error "fontFamily "ubuntu-bold" is not a system font and has not been loaded through Font.loadAsync."

What could be the problem? I'm really stumped on this one. I have just upgraded to Expo SDK 37.0.0, however I was having a similar problem prior to doing this, so I'm not sure that's the problem.

It also doesn't load in Ubuntu Regular, but it's Ubuntu-Bold that flashes up first with an error on Expo.

1

There are 1 best solutions below

1
On

watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && rm -f package-lock.json && rm -f yarn.lock && npm cache verify && npm install && expo r -c

try this