元素类型无效:预期为字符串(用于内置组件)或类/函数(用于组合组件),但got:未定义。检查“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>
);
}
}
更新:
弄明白了。组件应该是小写的。
发布于 2016-05-17 14:04:12
@qinking126已经能够解决这个问题,他评论了他的答案。
我只是在强调他的答案。。
<NavigatorIOS style={styles.container}
tintColor='#FF6600'
initialRoute={{
title: 'Hacker News',
Component: Dashboard,
}}/>
在这里,组件应该是小写的
像这样:-组件:仪表板,
多亏了qinking126
发布于 2016-03-07 10:32:04
您需要在HackerNews组件中导入仪表板类。
https://stackoverflow.com/questions/35841317
复制相似问题