export interface IActivity {
id: string;
title: string;
description: string;
category: string;
date: Date;
city: string;
venue: string;
isGoing: boolean;
isHost: boolean;
Attendees: IAttendee[]
}
All Data Without Filtering only view activities attendees
当我尝试查看所有数据时,控制台将显示正确的数据。但是,当我尝试从数组中过滤特定数据时,它会显示未定义。为什么Host
未定义?
const ActivityListItem: React.FC<{activity: IActivity}> = ({activity}) => {
const host = activity.Attendees.filter(a=> a.isHost)[0];
console.log("Host ", host);
return (
<Segment.Group>
<Segment>
没有索引[0]过滤器函数返回空数组 Without Index 0
请帮帮我。我被他们困住了,我尝试了其他功能,但是那些功能无法返回我的特定数据。