gpt4 book ai didi

react-native - react 原生 NavigatorIOS 错误 : Element type is invalid expected a string or a class/function

转载 作者:行者123 更新时间:2023-12-04 05:11:07 25 4
gpt4 key购买 nike

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'.

这是我的代码

/**
* 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>
);
}
}

更新:

想通了。组件应该是小写的。

最佳答案

@qinking126 已经能够解决这个问题,他评论了他的答案。

我只是在此处突出显示他的答案。

<NavigatorIOS style={styles.container}
tintColor='#FF6600'
initialRoute={{
title: 'Hacker News',
Component: Dashboard,
}}/>

这里 Component 应该小写

像这样:- 组件:仪表板,

感谢qinking126

关于react-native - react 原生 NavigatorIOS 错误 : Element type is invalid expected a string or a class/function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35841317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com