React Native iOS build Error - 检查类的渲染方法
Posted
技术标签:
【中文标题】React Native iOS build Error - 检查类的渲染方法【英文标题】:React Native iOS build Error - Check the render method of class 【发布时间】:2019-08-22 12:07:11 【问题描述】:我最近刚开始学习 React Native ios,我正在关注 raywenderlich 教程
https://www.raywenderlich.com/485-react-native-tutorial-building-ios-apps-with-javascript#toc-anchor-001
我正在使用以下版本:
react-native-cli: 2.0.1
react-native: 0.60.5
在添加导航部分,我遵循完全相同的步骤,但出现以下错误
"you likely forgot to export your component from the file it's defined in and you might have mixed up with default and named imports"
这是我的 App.js 文件代码
'use strict';
import React, Component from 'react';
import StyleSheet, Text, NavigatorIOS, View from 'react-native';
class SearchPage extends Component<>
render()
return <Text style=styles.description>Search for houses to buy!
</Text>;
class App extends Component<>
render()
return (
<NavigatorIOS
style=styles.container
initialRoute=
title: 'Property Finder',
component: SearchPage,
/>
);
const styles = StyleSheet.create(
description:
fontSize: 18,
textAlign: 'center',
color: '#656565',
marginTop: 65,
,
container:
flex: 1,
,
);
export default App;
Index.js 文件代码:
import AppRegistry from 'react-native';
import App from './App';
import name as appName from './app.json';
AppRegistry.registerComponent(appName, () => App);
请告诉我我做错了什么?提前谢谢!!!!
【问题讨论】:
您似乎缺少export default class App extends Component
。你能添加它然后再试一次吗?
No 最后我做了一行“导出默认应用程序;”..请检查!!!
遇到同样的错误...有什么建议吗?
【参考方案1】:
尝试检查 registerComponent 的导入
import AppRegistry from 'react-native';
import App from './App'; // <--- check here
AppRegistry.registerComponent('PropertyFinder', () => App);
【讨论】:
我的 index.js 文件代码就是这个。请检查问题编辑...以上是关于React Native iOS build Error - 检查类的渲染方法的主要内容,如果未能解决你的问题,请参考以下文章
react-native iOS release build 加载本地图片和图标时出错
Detox react-native build 成功,“Detox 似乎无法连接到测试应用程序!” (iOS)
将 xcode 更新到 9.4 后,react native ios build 失败。错误是“NSInteger”类型的值
React Native 0.63.2 iOS Build Error with `ld: library not found for -lAppAuth`
Appcenter Android Build for React-Native with Unity
React Native Build Error on IOS - typedef用不同类型重新定义('uint8_t'(又名'unsigned char')与'enum clockid_t')