我最近几天遇到此错误,但仍然找不到解决方法。error code ise here.
元素类型无效:预期使用字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义。您可能忘记了从定义的文件中导出组件,或者混合使用默认或命名的导入。
检查“ cellRenderer”方法的渲染
我将React更新为最新版本。但错误仍然继续。NPMversiyon ise 6.13.1。我认为错误很小,但我看不到。感谢您的帮助。
这是我的代码;
dataItem.js
import React, {Component} from 'react';
import {Body, Button, Left, ListItem, Right, Text, Thumbnail} from 'native-base';
class DataItem extends Component {
constructor(props) {
super(props);
this.data = props.data;
}
render() {
return (
<ListItem thumbnail>
<Left>
<Thumbnail
square
source={{
uri:
this.data.urlToImage != null
? this.data.urlToImage
: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWBAMAAADOL2zRAAAAG1BMVEXMzMyWlpajo6PFxcW3t7ecnJyqqqq+vr6xsbGXmO98AAAACXBIWXMAAA7EAAAOxAGVKw4bAAABPUlEQVRoge3Tv0/CQBjG8YcWaMcebymOENLI2MZoHMHEvVUKjq1K4lhM2Kvxx7/tUUiamDhc6GSez8INzbf3HleAiIiIiIiIiIiIiNozAGzvuJYTW2reXmso7bX8YN96HUR1a7RZ6+VVOgU+p4LuZGrSkqK0PWfwfl+3ht/hcpdvPkJ0g0fBYpYZtS7HttfPMatbAbZzJ1kjjnqVK1ihNzdpdX3b65S4qVsjXbG9EtuoEzliC/RbDFoIL7wY2NZrQayPzw1VpH/FUUqNjVrx0+9W8Rzrlt7yMMvMWq7fzHhoCTp6Rr0vw0uiH8+as69bov/AyNqf/Rms3Ky1aO7EYV93X2nlBIXg7WVSmrWs5q4eWrvVdYLbpR4/PTeZ8S9O82mdzMr7SVstV6mqrRaKh9ZSRERERERERET0n/wAZwMqI9kyPcoAAAAASUVORK5CYII=',
}}
/>
</Left>
<Body>
<Text numberOfLines={2}>{this.data.title}</Text>
<Text note numberOfLines={2}>
{this.data.description}
</Text>
</Body>
<Right>
<Button transparent>
<Text>OKU</Text>
</Button>
</Right>
</ListItem>
);
}
}
export default DataItem ;
tab1.js
import React, {Component} from 'react';
import {Alert, View, ActivityIndicator} from 'react-native';
import { Container, Content, List, Text } from 'native-base';
import {DataItem} from '../../component/dataItem';
import {getArticles} from '../../service/news';
export default class ListThumbnailExample extends Component {
constructor(props) {
super(props);
this.state= {
isLoading: true,
data: null
}
}
componentDidMount() {
getArticles().then(data => {
this.setState({
isLoading: false,
data: data
});
}
)
}
render() {
console.log(this.state.data);
let view = this.state.isLoading ? (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<ActivityIndicator animating={this.state.isLoading} color="#00f0ff" />
<Text style={{marginTop: 10}} children="Please Wait.." />
</View>
) : (
<List
dataArray={this.state.data}
renderRow={(item) => {
return (
<DataItem onPress={this.handleItemDataOnPress} data={item} />
)
}} />
)
return (
<Container>
<Content>
<List
dataArray={this.state.data}
renderRow={(item) => {
return <DataItem data={item}/>
}}
/>
</Content>
</Container>
);
}
}