I am just iterating some data from API using arrow function inside render function of react like this.
render() {
const postItem = this.props.posts.map((post, index) => {
<div key={post.id}>
<p>{index}</p>
<h4>{post.title}</h4>
<p>{post.body}</p>
</div>
})
return (
<div>
<p>Posts</p>
{postItem}
</div>
)
}
then it throws error
(Please look curly braces after arrow, if put "(" inplace of curly braces "{" then every things goes fine)
like "Expected an assignment or function call instead saw an expression", but if I put ( after => then everythings goes fine.But my doubt is that correct syntax of an arrow is like this () => {}.
Please help me out.