May 2018
Intermediate to advanced
470 pages
13h 54m
English
When a comment's delete button is clicked by the commenter, the Comments component will call the deleteComment method to fetch the uncomment API, and update the comments along with the comment count when the comment is successfully removed from the server.
mern-social/client/post/Comments.js:
deleteComment = comment => event => { const jwt = auth.isAuthenticated() uncomment({ userId: jwt.user._id }, { t: jwt.token }, this.props.postId, comment).then((data) => { if (data.error) { console.log(data.error) } else { this.props.updateComments(data.comments) } }) }
Read now
Unlock full access