This is the code i am trying to print out the comments through map function but cant figure out how:
class Postcomment2 extends React.Component {
uploadcomment = () => {
return this.props.post.comments.map((commentz) => {
return <div>{this.props.post.comments["comment"]}</div>;
}); /* How to access sub array of comments and print them all */
};
render() {
return (
<div>
<div>{this.uploadcomment()}</div>
</div>
);
}
}
in this Post is the array of objects and the data is:
{
imageUrl:
"https://i.pinimg.com/originals/83/6c/8a/836c8a66349fecbc0a06c4cc3d41e031.jpg",
user: Users[0].user,
likes: 410,
caption:
"Here at kingdom tower... #KSA #KingdomTower #React JS #This is getting too long #Peace",
profilepic: Users[0]["image"],
comments: [
{
user: "zoraiz",
comment: "Nicee!"
},
{
user: "asher",
comment: "Alrightttt!!"
},
{
user: "hamis",
comment: "Interesting...."
}
]
},