admin管理员组文章数量:1356377
So, I have a dictionary with keys and an array of Objects as values for each key. What I need to do is render a new ponent with props ing from Object for each element of the array. This is how the it looks.
1:
[
Object {
"ClassId":232,
"Teacher":"TeacherName"
...
}
Object {
"ClassId":21,
"Teacher":"TeacherName"
...
}
...
]
This is the code I have right now but somehow the ponent does not render to the screen.
timetable[key]["value"]. The value field is there because the actual value for a key is another dictionary, but I'm only using the value. Printing the elements in the console instead of passing them as props to the CourseCard ponent looks good, the data is there.
{Object.keys(timetable).map((key, index) => {
timetable[key]["value"].map(iter => {
return (
<CourseCard
teacher={iter["Teacher"]}
course={iter["ClassName"]}
classRoom={iter["ClassRoom"]}
time={iter["Time"]}
key={iter["Key"]}
/>
);
});
})}
So, I have a dictionary with keys and an array of Objects as values for each key. What I need to do is render a new ponent with props ing from Object for each element of the array. This is how the it looks.
1:
[
Object {
"ClassId":232,
"Teacher":"TeacherName"
...
}
Object {
"ClassId":21,
"Teacher":"TeacherName"
...
}
...
]
This is the code I have right now but somehow the ponent does not render to the screen.
timetable[key]["value"]. The value field is there because the actual value for a key is another dictionary, but I'm only using the value. Printing the elements in the console instead of passing them as props to the CourseCard ponent looks good, the data is there.
{Object.keys(timetable).map((key, index) => {
timetable[key]["value"].map(iter => {
return (
<CourseCard
teacher={iter["Teacher"]}
course={iter["ClassName"]}
classRoom={iter["ClassRoom"]}
time={iter["Time"]}
key={iter["Key"]}
/>
);
});
})}
Share
Improve this question
asked Mar 26, 2018 at 12:00
Radulescu PetruRadulescu Petru
1372 silver badges8 bronze badges
1 Answer
Reset to default 10You need to return the result of inner map function,
{Object.keys(timetable).map((key, index) => {
return timetable[key]["value"].map(iter => {
return (
<CourseCard
teacher={iter["Teacher"]}
course={iter["ClassName"]}
classRoom={iter["ClassRoom"]}
time={iter["Time"]}
key={iter["Key"]}
/>
);
});
})}
本文标签: javascriptComponent not rendering inside map functionReact NativeStack Overflow
版权声明:本文标题:javascript - Component not rendering inside map function-React Native - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743985870a2571274.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论