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
請注意,沒有其他文件被編輯。