我正在通过浏览器上的Snacks.expo运行react-native应用。最近我遇到了错误。一切似乎都源于我用来获取api的文件。
Evaluating module://expo-font.js
Evaluating module://react-native-elements.js
Evaluating module://containers/fetchAPI.js
Evaluating module://MainApplication.js
Evaluating module://App.js
Loading module://App.js
您能建议可能是什么原因吗?可能是我的代码中的东西。
答案 0 :(得分:1)
在Snack界面中,我更新了package.json并且它可以工作。关键是添加“ expo-font”:“ ^ 1.0.0”。在幕后它解析为expo-font@1.1.0。
"dependencies": {
"@babel/core": "^7.0.0",
"react-native-elements": "^1.0.0-beta7",
"expo-font": "^1.0.0",
"expo-asset": "~1.1.1",
"expo-file-system": "~1.1.0",
"expo-constants": "~1.1.0"
}
答案 1 :(得分:0)
import Expo from 'expo';
...
constructor(props) {
super(props);
this.state = {
isReady: false,
}
async componentWillMount() {
await Expo.Font.loadAsync({
Roboto: require('native-base/Fonts/Roboto.ttf'),
Roboto_medium: require('native-base/Fonts/Roboto_medium.ttf'),
});
this.setState({ isReady: true });
}
)
render() {
if (!this.state.isReady) {
return <Expo.AppLoading />;
}
return (//Your component);