I am building a website that is run locally.
I have a database that looks like this:
"posts":
{
"0":
{
"count": 5
},
"1":
{
"postID": 1,
"user": 1,
"showComments": false,
"date": 1451606400,
"upvotes": 127,
"downvotes": 6790,
"lat": 42.389825,
"long": -72.528267,
"commentsIDList": [1,2], // when implementing comments, store them by ID so they can be ontained easily
"postText": "Lorem ipsum dolor sit amet"
},
}
I want to dynamically pull the 'postText' by mapping over the db entries. So far I have this:
<div className="feed-body">
{this.state.postsText[this.state.active].posts.map( (map, i) => {
return (
<Post key={i + (this.state.active * 1000)} parentId={this.state.posts[this.state.active].userID} data={map} />
);
})}
</div>
However, every time I ran the main page doesnt load. When I remove this piece of code from my index.js file, everything works fine, except that nothing is pulled from the db. So I know the error is in this of code, I just don' know if I am pulling the right way.
Aucun commentaire:
Enregistrer un commentaire