【发布时间】:2017-08-25 11:18:47
【问题描述】:
打开应用时显示错误。
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.
这是我创建的基本代码。查看重现的步骤:
- 使用命令
create-react-native-app AwesomeProject创建了本机项目 - 已安装
npm install --save react-navigation -
将以下代码从反应导航文档中粘贴到 App.js
import React from 'react'; import { AppRegistry, Text, } from 'react-native'; import { StackNavigator } from 'react-navigation'; class HomeScreen extends React.Component { static navigationOptions = { title: 'Welcome', }; render() { return <Text>Hello, Navigation!</Text>; } } const SimpleApp = StackNavigator({ Home: { screen: HomeScreen }, }); AppRegistry.registerComponent('SimpleApp', () => SimpleApp); 使用
npm start运行应用并在expo app android中打开
请注意,其他文件均未编辑。
【问题讨论】:
标签: javascript android reactjs react-native react-navigation