簡體   English   中英

無效錯誤中的新react-native 0.43.3項目元素類型

[英]new react-native 0.43.3 project Element Type in invalid error

如果我創建一個新的文件夾應用程序並在其中創建index.js文件,它是一個簡單的React組件,呈現文本Hello world即

export default class Test extends Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          Hello WOrld
        </Text>
      </View>
    );
  }
}

然后在index.ios.js中,我調用:

import React, { Component } from 'react';
import { AppRegistry } from 'react-native'
import Test from './app'

AppRegistry.registerComponent('Test', () => Test)

我收到元素類型無效的錯誤:

需要一個字符串(用於內置組件)或一個類/函數,但是得到了對象。

但是,如果我在index.ios.js中創建該組件,則該組件會很好地呈現。

我的應用文件夾結構:

Test
 app
  index.js
 index.ios.js

起作用的是import Test from './app/index';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM