React native React Native Expo“;加载”;错误

React native React Native Expo“;加载”;错误,react-native,expo,React Native,Expo,我有一个关于Expo的React原生项目,我在我的Android手机上安装了Expo客户端。到目前为止,它一直运作良好。但是,即使我没有更改任何代码,我现在在扫描手机上的二维码时出现以下错误。此错误显示在终端上,电话屏幕保持空白 import React from 'react'; import { Image } from 'react-native'; import { AppLoading } from 'expo'; import { Asset } from 'expo-ass

我有一个关于Expo的React原生项目,我在我的Android手机上安装了Expo客户端。到目前为止,它一直运作良好。但是,即使我没有更改任何代码,我现在在扫描手机上的二维码时出现以下错误。此错误显示在终端上,电话屏幕保持空白

    import React from 'react';
import { Image } from 'react-native';
import { AppLoading } from 'expo';
import { Asset } from 'expo-asset';
import { Block, GalioProvider } from 'galio-framework';

import Screens from './navigation/Screens';
import { Images, articles, ditsTheme } from './constants';

// cache app images
const assetImages = [
  Images.Onboarding,
  Images.LogoOnboarding,
  Images.Logo,
  Images.Pro,
  Images.DITSLogo,
  Images.iOSLogo,
  Images.androidLogo
];

// cache product images
articles.map(article => assetImages.push(article.image));

function cacheImages(images) {
  return images.map(image => {
    if (typeof image === 'string') {
      return Image.prefetch(image);
    } else {
      return Asset.fromModule(image).downloadAsync();
    }
  });
}

export default class App extends React.Component {
  state = {
    isLoadingComplete: false,
  }

  render() {
    if(!this.state.isLoadingComplete) {
      return (
        <AppLoading
          startAsync={this._loadResourcesAsync}
          onError={this._handleLoadingError}
          onFinish={this._handleFinishLoading}
        />
      );
    } else {
      return (
        <GalioProvider theme={ditsTheme}>
          <Block flex>
            <Screens />
          </Block>
        </GalioProvider>
      );
    }
  }

  _loadResourcesAsync = async () => {
    return Promise.all([
      ...cacheImages(assetImages),
    ]);
  };

  _handleLoadingError = error => {
    // In this case, you might want to report the error to your error
    // reporting service, for example Sentry
     warn(error);
  };

  _handleFinishLoading = () => {
    this.setState({ isLoadingComplete: true });
  };

}
从“React”导入React;
从“react native”导入{Image};
从“expo”导入{AppLoading};
从“expo资产”导入{Asset};
从“galio框架”导入{Block,GalioProvider};
从“./navigation/Screens”导入屏幕;
从“./constants”导入{图像、文章、编辑时间};
//缓存应用程序图像
常数资产=[
图像,登机,
图像。登录,
图像,标志,
图片,专业版,
Images.DITSLogo,
Images.ios徽标,
安卓伊洛哥图片
];
//缓存产品映像
articles.map(article=>assetImages.push(article.image));
函数缓存图像(图像){
返回images.map(image=>{
如果(图像类型==='string'){
返回图像。预取(图像);
}否则{
return Asset.fromModule(image).downloadsync();
}
});
}
导出默认类App扩展React.Component{
状态={
isLoadingComplete:false,
}
render(){
如果(!this.state.isLoadingComplete){
返回(
);
}否则{
返回(
);
}
}
_loadResourcesAsync=async()=>{
回报你的承诺([
…缓存图像(资产评估),
]);
};
_handleLoadingError=错误=>{
//在这种情况下,您可能希望将错误报告给您的错误
//报告服务,例如哨兵
警告(错误);
};
_handleFinishLoading=()=>{
this.setState({isLoadingComplete:true});
};
}

如何解决此错误?

在您的
\u handleLoadingError
方法中,您正在使用
warn
。当您应该使用
控制台时。警告
。这就是破坏你的应用程序的原因。

我遇到了这个错误,问题在于应用程序加载。问题是我调用的函数名不正确

下面请注意,我使用的是Font.loadAsync(缺少c),修复它可以正确加载字体

const getFonts = () =>  Font.loadAsyn({
      'nanitu-regular' : require('./assets/fonts/EastSeaDokdo-Regular.ttf'),
      'nanitu-bold' : require('./assets/fonts/NanumBrushScript-Regular.ttf')
  })

)

你在用什么电话?什么手机可以正常工作?这通常意味着AppLoading async函数失败。我在Android Emulator和另一台Android设备上运行一个应用程序,但在这两台设备上都出现了错误。但你说“它在另一台手机上无缝工作。”。哪部手机?是的,它正在工作,但现在它只会在每部手机和模拟器中显示错误。您可以共享
startAsync
功能的内容吗?