April 2020
Intermediate to advanced
716 pages
18h 55m
English
The updateComments method, which will allow the comments and comment count to be updated when a comment is added or deleted, is defined in the Post component and passed as a prop to the Comments component. The updateComments method will look as follows:
mern-social/client/post/Post.js:
const updateComments = (comments) => { setValues({...values, comments: comments})}
This method takes the updated list of comments as a parameter and updates the state that holds the list of comments rendered in the view. The initial state of comments in the Post component is set when the Post component mounts and receives the post data as props. The comments that are set here are sent as props to the Comments component and used to render ...
Read now
Unlock full access