无法读取未定义的属性(读取“地图”)类型错误:无法读取未定义的属性(读取“地图”)收到此错误

问题描述 投票:0回答:1

This is Cards components where error is being showed This is error shown by the code

尝试使用api调用映射数据,但映射出现错误。尝试解决这个问题很长时间,请帮忙解决这个问题。

javascript reactjs react-hooks components mapping
1个回答
0
投票

问题似乎出自那里:

getCourses().map((course) => (
  <Card key={course.id}
    course={course}
    likedCourses={likedCourses}
    setLikedCourses={setLikedCourses}
  />
))

据我所知,对

getCourses
的调用会返回
undefined

由于您从该函数返回

allCourses
courses[category]
,我想说您有时会使用
Cards
对象中不存在的
category
来调用您的
courses
组件。

您可以在类似的帖子中找到更多信息:× TypeError:无法读取未定义的属性(读取“地图”)

© www.soinside.com 2019 - 2024. All rights reserved.