React is mapping duplicate posts
like this
Ideally im just looking to map the likes array.
{myLikes.map(like =>
)}
within the posts, i don't want duplicates posts. How would i achieve that ?
PostList.js
render(){
const {posts, myLikes} = this.props;
return (
<div>
{posts.map(post => (
<div>
{myLikes.map(like =>
<Paper key={post.id} style={Styles.myPaper}>
<PostItem
myLikes={like}
myTitle={this.state.title}
editChange={this.onChange}
editForm={this.formEditing}
isEditing={this.props.isEditingId === post.id}
removePost={this.removePost}
{...post}
// {...like}
/>
</Paper>
)}
</div>
))}
</div>
)
}
}
const mapStateToProps = (state) => ({
isEditingId: state.post.isEditingId,
myLikes: state.post.likes // reducer likes
})
Posts
Likes





map(), if you are using lodash, tryuniqBy()to remove duplicate value.