BeginnerCoder

Lesson 17 — Mini project: todo list

Your first small app

A todo list combines everything so far: a controlled input for the text, state for the list, and a click handler that adds an item. Never push into the state array — create a new array with spread, then clear the input so the user can type the next item.

setTags([...tags, newTag]); // new array: React sees the change
// tags.push(newTag)        ← same array: React may not re-render

Why it matters: this add-to-list flow appears in comments, carts, playlists and chats.

Want it another way?
Task

Finish add(). Typing Milk → Add, then Eggs → Add should show both in the list and empty the box.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.

Keep going with React Foundations

Ready for more? Optional paid resources that pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.