刚开始探索React Native但不幸的是,我遇到了这个错误
App(...):必须返回有效的React元素(或null)。你可以 已返回undefined,数组或其他一些无效对象
我已尝试检查并参考其他问题,但无法弄明白。请检查附加的屏幕截图 - 这是我的index.ios看起来像
的方式import React from 'react';
import { AppRegistry, View } from 'react-native';
import Header from './src/components/Header';
import AlbumList from './src/components/AlbumList';
//Create a Component
const App = () => {
<View>
<Header headerText={'Albums'} />;
<AlbumList />
</View>;
};
//Render it to the device
AppRegistry.registerComponent('albums', () => App);
任何建议都会非常有帮助
谢谢。
答案 0 :(得分:1)
尝试在App
函数中添加一个回复:
const App = () => {
return (
<View>
<Header headerText={'Albums'} />;
<AlbumList />
</View>
);
};