typescript - 如何使用带有 Typescript 的 expo AppLoading 组件?
问题描述
我正在尝试将基于 expo 的 react 本机应用程序重写为 TypeScript,并且 AppLoading 组件会生成一些我不知道如何处理 TypeScript 样式的错误。
编码:
if (!this.state.isLoadingComplete && !this.props.skipLoadingScreen) {
return (
<AppLoading
startAsync={this.loadResourcesAsync}
onError={this.handleLoadingError}
onFinish={this.handleFinishLoading}
/>
);
} else {
return (
<View style={Styles.container}>
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
<AppNavigator />
</View>
);
}
public loadResourcesAsync = async (): Promise<any> => {
return Promise.all([
Asset.loadAsync([
require('./assets/images/bankid.png'),
]),
Font.loadAsync({
// This is the font that we are using for our tab bar
...Icon.Feather.font,
// We include SpaceMono because we use it in HomeScreen.js. Feel free
// to remove this if you are not using it in your app
'scala-sans-regular': require('./assets/fonts/ScalaSans-Regular.ttf'),
'scala-sans-bold': require('./assets/fonts/ScalaSans-Bold.ttf'),
}),
])
};
private handleLoadingError = error => {
// In this case, you might want to report the error to your error
// reporting service, for example Sentry
logError("_handleLoadingError", {
error: error
});
console.warn(error);
};
private handleFinishLoading = () => {
this.setState({ isLoadingComplete: true });
};
这是打字稿编译器给出的错误,遗憾的是我不知道它要我做什么
解决方案
推荐阅读
- forms - 选择相同元素时Vue表单选择发出事件
- excel - 将值从 30 本书复制到一本书 - Excel VBA
- codenameone - Cloudinary 图像未显示在 IOS 调试版本上
- r - 为什么将.txt文件导入R时所有变量都压缩为一列
- c - readlines 函数将文本从文件逐行插入到指针传递的字符串数组中
- excel - 如何通过 WebBrowser 运行 Internet Explorer 应用程序?
- reactjs - 我可以将表单输入放在反应组件中吗?
- php - 使用 map_meta_cap 防止访问某些帖子、页面、附件和类别术语
- javascript - 传单地图未正确呈现
- typescript - 异步等待,继续没有捕获