React Native(Expo)如何设置默认字体(或者是全局字体)?

React Native(Expo)如何设置默认字体(或者是全局字体)?

如果自定义一个Text组件, 可能要异步加载,如下:


  componentWillMount = async () => {

    await Font.loadAsync({

      'a: require('../fonts/aaa.ttf'),

      'b': require('../fonts/bbb.ttf')

    });

    this.setState({ fontLoaded: true });

  };

那么可能会出现如下错误:


Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.


UYOU
浏览 487回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript