React.createElement:类型在Expo上无效 [英] React.createElement: type is invalid on Expo
本文介绍了React.createElement:类型在Expo上无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚开始学习React Native,并尝试在Expo上进行RN.现在我收到了这个错误.
I'm just starting to learn React Native and I tried to do RN on Expo. Now I'm getting this error.
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 文件
推荐答案
您可以这样做:
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 );
这篇关于React.createElement:类型在Expo上无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文