我刚刚开始学习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 文件
上打开了这个鳕鱼答案 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 );