元素类型无效:应为字符串(对于内置组件)或 class/function 但得到的是:对象。

Element type is invalid: expected a string (for built-in components) or a class/function but got: object.

我知道这个问题已经被问过很多次了,但我阅读的解决方案并不适用于我的情况。我的代码超级简单明了:

// Import a library to help create a component
import React from 'react';
import { AppRegistry, Text } from 'react-native';

//Only access text and AppRegistry from React-native lib

//Create a component
const App = () => (
    <Text>Some Text</Text>
);

//Render it to the device
AppRegistry.registerComponent('myapp2_albums', () => App);

我正在使用 expo 开发 ios 应用程序。它一直显示 Element type is invalid: expected a string (for built-in components) or a class/function but got: object.您可能忘记从定义组件的文件中导出组件。

检查“AwakeInDevApp”的渲染方法

任何见解将不胜感激:)

React native 有时会挑剔地将字段包装在视图中并为其赋予 1 的弹性。

import React from 'react';
import { AppRegistry, Text } from 'react-native';

//Only access text and AppRegistry from React-native lib

//Create a component
  export default const App = () => {
  return (
   <View style={{ flex: 1}}>
       <Text>Some Text</Text>
   </View>
  );
};

//Render it to the device
AppRegistry.registerComponent('myapp2_albums', () => App);