我无法获得反应导航工作的示例。我总是以错误Element 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.
这是使用intro page
中的示例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);
我正在为iOS构建并在设备上运行(而不是模拟器)。
答案 0 :(得分:0)
我认为您错过了导出HomeScreen类:
class HomeScreen extends React.Component {
用
替换它export default class HomeScreen extends React.Component {