Interactive Comments Section

Solution retrospective
feedback would be appreciated
Please log in to post a comment
Log in with GitHubCommunity feedback
- @mseidel819
This looks good! I like the way you implemented the "time posted" feature. I was just using dates, so I want to look into how you did that.
When I upvote the 1st level comments, they aren't sorting. Try moving your sort function around to another place. From what I think I see, you initialize
comments
with a sorted array, but they never sort again after that first time. For example, what I did in my app was to sort the comments in the return function: {{ comments_map.sort((a, b) => { return b.score - a.score; }).map(comment => { return ( <Comment key={comment.id + comment.user.username} comment={comment} comments={comments} setComments={setComments} currentUser={currentUser} /> ) }) }
}
now, each time this component re-renders due to an updated state, it will sort the comments accordingly.
Marked as helpful
Join our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord