1
我正在处理React-Native项目,并在尝试实施反应导航时遇到问题。 我也跟着教程,并试图运行项目时,我得到的是说,一个错误:元素类型无效:期望得到字符串/类/函数:对象
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.
我在网上搜索,包括这个网站,但无法找到任何解决方案。 这是我的代码: index.js:
import React, { Component } from 'react';
import { Stack } from './config/Router';
class Application extends Component{
render(){
<View>
return <Stack />;
</View>
}
}
export default Application;
这是路由器:
import React from 'react';
import { StackNavigator } from 'react-navigation';
import Login from '../components/Login';
import Home from '../components/Home';
export const Stack = StackNavigator({
Login:{
screen: Login
},
Home:{
screen: Home,
navigationOptions: {
title: 'Home'
}
}
});
,这是index.ios.js:
import { AppRegistry } from 'react-native';
import Application from './index'
AppRegistry.registerComponent('Application',() => Application);
如何解决错误?提前致谢!
谢谢,但我仍然有同样的错误。 –
@JohnDoah你可能需要在index.js中导入'View'组件 – Emobe