繁体   English   中英

React Native iOS构建错误-检查类的render方法

[英]React Native iOS build Error - Check the render method of class

我最近才刚开始学习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); 

请告诉我我做错了什么? 提前致谢!!!!

尝试不检查registerComponent的导入

import { AppRegistry } from 'react-native';
import App from './App'; // <--- check here

AppRegistry.registerComponent('PropertyFinder', () => App);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM