react-native - 在 SDK 40 上反应本机博览会警告
问题描述
我正在做一个基本的 react native expo 应用程序,我有这个警告:
Your project is accessing the following APIs from a deprecated global rather than a module import: Font (expo-font).
The global "__expo" and "Expo" objects will be removed in SDK 41. Learn more about how to fix this warning: https://expo.fyi/deprecated-globals
我该如何解决?(不仅忽略警告,我还想解决这个问题)。我的代码是:
// RNRF logic here
import React, { Component } from 'react';
import {
StyleSheet,
TouchableOpacity,
Text,
View,
} from 'react-native'
import AppLoading from 'expo-app-loading';
import * as Font from 'expo-font';
import { Ionicons } from '@expo/vector-icons';
import { Container, Root} from 'native-base';
import Constants from 'expo-constants';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
isReady: false,
};
}
async componentDidMount() {
await Expo.Font.loadAsync({
'Roboto': require('native-base/Fonts/Roboto.ttf'),
'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf'),
...Ionicons.font,
});
this.setState({ isReady: true });
}
render(){
if (!this.state.isReady) {
return <AppLoading />;
}
return(
<View>
<Text>Hello</Text>
</View>
);
}
}
谢谢................................................. ……
解决方案
尝试从“componentDidMount”函数中删除单词“Expo”,因为您已经从“expo-font”导入“Font”
推荐阅读
- javascript - 使用javascript在文本中查找不同格式的日期
- php - Laravel 5.5 从 5.4 升级得到错误
- android - 如何在多个 TextureView 中显示相同的视频?
- php - 如何在我的网站上的 shell 中运行 php 脚本?
- macos - 无法在 VS2017 7.6 中打开 Specflow 功能文件(适用于 MAC)
- python - Wagtail API - 如何公开片段
- python - 通过 Halley 方法使用 tensorflow 求 4 次多项式的根
- microsoft-teams - Microsoft Teams 需要什么条件才能创建传出 Webhook?
- python - django 默认日期格式为 %d-%m-%Y
- jira - 如何获取最近两周打开的已完成项目的状态