0
打开应用程序时显示错误。React本地导航包错误React.createElement:类型无效 - 预期为字符串
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
并在博览会应用程序中打开android
请注意,没有其他文件被编辑。