这是我第一次使用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)
1 回答
尝试将'albums'更改为'AwakeInDevApp',当您运行
react-native init YourProjectName
时,它必须是您的项目名称