老师我继承baseItem这里报错
来源:9-2 收藏功能的实现-1【实战应用】
慕婉清5431680
2020-03-01
报错是 : undefined is not an object (evaluating _this.props.projectModel) is located at PopularItem(at PopularPage.js 115) ,我看了下声明了属性但是一直报这个错,我继承baseitem就可以,一下是代码,求老师帮忙看一下
// popularPage页面
renderItem (data) {
const item = data.item;
return <PopularItem
ref = {(ref) => this.refDom = ref}
projectModel = {item}
onSelect = {() => {
NavigationUtil.goPage({
projectModel: item,
}, ‘DetailPage’);
}}
onFavorite = {(item, isFavorite) =>FavoriteUtil.onFavorite(favoriteDao,item ,isFavorite, FLAG_STORAGE.flag_popular)}
/>;
}
// popularItem页面
import React, {Component} from ‘react’;
import {Image, StyleSheet, Text, TouchableOpacity, View} from ‘react-native’;
import FontAwesome from ‘react-native-vector-icons/FontAwesome’;
import BaseItem from ‘./BaseItem’;
export default class PopularItem extends BaseItem {
render() {
const {projectModel} = this.props;
const {item} = projectModel;
if (!item || !item.owner) {
return null;
}
// BaseItem页面
import React, {Component} from ‘react’;
import {Image, StyleSheet, Text, TouchableOpacity, View} from ‘react-native’;
import FontAwesome from ‘react-native-vector-icons/FontAwesome’;
import HTMLView from ‘react-native-htmlview’;
import {PropTypes} from ‘prop-types’;
export default class BaseItem extends Component {
static propTypes={
projectModel: PropTypes.object,
onSelect: PropTypes.func,
onFavorite: PropTypes.func,
}
constructor(props) {
super();
this.state = {
isFavorite: this.props.projectModel.isFavorite,
};
}
1回答
-
CrazyCodeBoy
2020-06-12
单词的大小写拼错了,P改成p
00 -
慕婉清5431680
提问者
2020-03-01
断点看了取出来的item是有数据的 是被projectmodal包裹的对象数据
012020-06-11
相似问题