April 2020
Intermediate to advanced
716 pages
18h 55m
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. The deleteComment method is defined as follows.
mern-social/client/post/Comments.js:
const deleteComment = comment => event => { uncomment({ userId: jwt.user._id }, { t: jwt.token }, props.postId, comment).then((data) => { if (data.error) { console.log(data.error) } else { props.updateComments(data.comments) } }) }
On successfully removing a comment from the backend, the updateComments method that's sent in the props from the Post component will be invoked. ...
Read now
Unlock full access