老师我继承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

0
0

慕婉清5431680

提问者

2020-03-01

断点看了取出来的item是有数据的 是被projectmodal包裹的对象数据//img.mukewang.com/szimg/5e5ba2ec096f98b907440130.jpg

0
1
CrazyCodeBoy
单词的大小写拼错了,P改成p
2020-06-11
共1条回复

RN入门到进阶,打造高质量上线App

解锁React Native开发应用新姿势,React Native新版本热门技术

3144 学习 · 3241 问题

查看课程