React.createElement:类型在Expo上无效

时间:2017-07-28 05:03:00

标签: reactjs react-native expo

我刚刚开始学习React Native,我试图在世博会上做RN。现在我收到了这个错误。

Warning: React.createElement: type is invalid -- expected a string (for 
built-in components) or a class/function (for composite components) 
but got: object. You likely forgot to export your component from the 
file it's defined in.

我的代码是

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

const App = () => (
    <Text>Some Text </Text>
    );


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

我在 App.js 文件

上打开了这个鳕鱼

1 个答案:

答案 0 :(得分:1)

你可以这样做:

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

export default class App extends Component {
  render() {
    return (
      <Text>Hello world!</Text>
    );
  }
}


AppRegistry.registerComponent('helloworld', () => App );
相关问题