Accepted answer
post = (item, key) {
            return <Post title={item.title} content={item.content} key={key}/>

Your state.posts is an array and you should map over it.


post = Object.keys(this.state.posts).map((item, key) => {
    return (

as Subin says, what you need to do in that case is just map over the posts array.

But, to fix your code is very simple. just use arrow function instead of a regular function.


Do it like this:

post = => {
  return <Post title={post.title} content={post.content} key={post.title}/>

When you map over array, you dont need to acces that state again, because post will be assigned to post inside map function. And then just acces title and content. and dont forget to pass key,there i've passed key={post.title} but that is not a good solution, because it needs to be unique.

Related Query

More Query from same tag