Element type is invalid: expected a string(for built-in components) or a class/function (for composite components) but got: undefined. check the render method of 'NavigatorIOS'.阵营本地NavigatorIOS错误:元素类型是无效的预期字符串或类/函数
这里是我的代码
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
import React, {
AppRegistry,
StyleSheet,
NavigatorIOS,
View,
Text,
} from 'react-native';
var Dashboard = require('./App/Views/Dashboard/index.ios.js');
class HackerNews extends React.Component {
render() {
return (
<NavigatorIOS style={styles.container}
tintColor='#FF6600'
initialRoute={{
title: 'Hacker News',
Component: Dashboard,
}}/>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#F6F6FF',
},
});
AppRegistry.registerComponent('HackerNews',() => HackerNews);
仪表板代码:
'use strict';
import React, {
StyleSheet,
Text,
View,
TouchableHighlight,
} from 'react-native';
//var api = require("../../Network/api.js");
//var Post = require("../Post/index.ios.js");
export default class Dashboard extends React.Component {
constructor(props){
super(props);
this.state = {
topStoryIDs: null,
lastIndex: 0
};
}
render(){
return(
<View>
<Text>Dashboard Testing</Text>
</View>
);
}
}
更新:
弄清楚了。组件应该是小写的。
你忘了在'HackerNews'类定义之前导入'Dashboard'类,可能是什么? – Cherniv