Comment
In this section we want to add the functionality of commenting under the news.
#
1. Create CommentList ComponentFirst we need to update the fields of usePost
in the NewsPage.tsx
to retrieve the replies.
Now we can create our CommentList component.
note
We are also getting the authMemberProps
for the replies, therefore we can easily reuse our DeleteNews
component
to have the functionality of deleting comments.
#
2. Create CommentComposer ComponentWe use useAddReply
hook to reply to a post. We can easily create a component that comments under a post.
note
We used the id of the "Comment" post type. If you are using your own community
use the postTypes
query to find the id of the "Comment" post type.
#
3. Update NewsPage to show the commentsNow we can easily add these components to our NewsPage component.
Now it's all set. You can start viewing, adding, and deleting comments.
note
You can see the final result here.