javascript - React Native iOS 构建错误 - 检查类的渲染方法

标签 javascript ios react-native react-native-ios react-native-navigation

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

关于javascript - React Native iOS 构建错误 - 检查类的渲染方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57609018/

相关文章:

javascript - 使用 jQuery 更改模态内容

ios - 应用程序进入后台后未调用 AFNetworking 成功/失败 block

ios - 如何在 Swift 中将 Microsoft Word 文档渲染为 .png 图像

ios - 我们可以在 react-native 中设置组件的内容优先级吗?

css - react native 图像不显示

javascript - 轨迹球控件从何而来?

javascript - 如何在 Eclipse 中为 JavaScript 项目的 DOM 启用代码辅助

javascript - 通过 Wordpress Divi 主题代码模块为图像内部的图像设置动画

ios - 处理同一帐户下多个应用程序的身份验证 - iOS

ios - React Native iOS Release 构建停留在旧代码上,但 Debug 构建工作正常