Flattening a comment thread into a single array works until you need to reply to a reply. Then you're faking depth with parent ids, and every edit or delete means rebuilding the whole list. A recursive tree keeps the shape of the conversation and lets you update just the branch that changed.
π§© Overview
Build a threaded comments UI: render a recursive thread, then reply, edit, collapse, and delete nodes while every update returns a new tree instead of mutating the seed.
π https://www.reactchallenges.com/challenges/nested-comments
β
Requirements
Render the full thread from initialComments , with replies nested inside their parent.
Each comment shows its author and text, and exposes reply, edit, and delete controls.
Comments with replies get a collapse control with aria-expanded that hides or shows only their replies.
Replying opens a form, appends a trimmed reply authored by "You", and closes it.β¦