在尝试渲染React Native应用程序时,我在模拟器中收到此错误

时间:2017-07-22 01:22:38

标签: react-native

这是我第一次使用react native。我正在学习一个教程,但我的结果与教程不同。我已经对我的代码进行了三次检查,并且它与显示的完全相同,但是我收到了这个错误。有什么想法吗?

// Import a library to help create a Component

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

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

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

错误是

警告:React.createElement:type无效 - 期望一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:object。您可能忘记从其定义的文件中导出组件。

Check the render method of `AwakeInDevApp`.
    in AwakeInDevApp (at registerRootComponent.js:21)
    in ExponentRootComponent (at renderApplication.js:35)
    in RCTView (at View.js:128)
    in View (at AppContainer.js:93)
    in RCTView (at View.js:128)
    in View (at AppContainer.js:92)
    in AppContainer (at renderApplication.js:34)

Screenshot of Error in Simulator

1 个答案:

答案 0 :(得分:0)

尝试将“相册”更改为“AwakeInDevApp”,当您运行react-native init YourProjectName时,它必须是您的项目名称

相关问题