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.
相关分类