Advanced React 10 · Project and summary
Final project: Kanban
Put everything together into one app.
Loading lesson…
Advanced React 10 · Project and summary
Put everything together into one app.
Loading lesson…
Nobody builds a house by hanging the curtains first and then looking for where to put the walls. The order is the opposite: a plan (where the rooms will be), the foundations, the shell, then the wiring and plumbing – and the furniture last. Each phase stands on the previous one, and when the foundations are done well, the upper floors hold up on their own.
An app is built the same way:
Now it's time to put everything together. Build a Kanban board (the columns "To do", "In progress" and "Done", between which you move task cards) – a small but real app that uses most of what you've learned. Work through the milestones and tick each one off.
Kanban (Japanese for "signboard") is a way to keep track of work: every task is a small card, and the cards move from left to right as the work progresses. From the user's point of view, the finished board will:
Before you tackle the whole kanban, warm up on its smallest part – a single card.
Task is in the comments in the code below – at the top of the file and at the places marked TODO.
row, stack, card, list, btn, input or muted are the course's ready-made styles in src/styles.css (row = side by side, stack = stacked, card = bordered box, muted = grey text).Loading the interactive part…
You don't start from an empty file. The project skeleton (the editor at the end of the page) already has the types, sample data and all the components with their finished look – you only fill in the behaviour at the places marked TODO (milestone N). This is how the components fit together (each one is inside the one above it):
Kanban the whole app└─ BoardProvider holds the cards (useReducer) and sends them down through two contexts└─ Board the bar with search, filter and Undo + three columns├─ Column ×3 one column: a heading with the card count and the list│ ├─ CardItem one card: the title (opens editing) and the ← → arrows│ └─ NewCardForm the "+ New card" field (only in the To do column)└─ CardModal the window for editing a card (only when one is open)└─ Modal a general window: portal, Escape, cursor in the first field
The table shows where in the code each milestone is and whether it's already prepared. Just read through the "done" milestones so you know how they work, and tick them off:
| Milestone | Where in the code | In the skeleton |
|---|---|---|
| 1. Types | the Types section at the top | ✅ done – read through it |
| 2. Reducer | the boardReducer function | ✏️ you fill in three branches |
| 3. Showing the columns | Column and Board | ✅ done – read through it |
| 4. Adding a card | NewCardForm | ✏️ you fill in the form submit |
| 5. Moving cards | the card_moved branch and the arrows in CardItem | ✏️ you fill in |
| 6. Context | BoardProvider, useBoard, useBoardDispatch | ✅ done – read through it |
| 7. Editing in a modal | Modal and CardModal | ✏️ you fill in |
| 8. Filter and search | the visible variable in Board | ✏️ you fill in |
| 9. Persistence | usePersistentBoard | ✏️ you fill in |
| Bonuses | the undo branch, CardItem, Column | ✏️ optional |
The whole project rests on one cycle you know from Hooks 03 and Hooks 04. Once you understand it on one click, you understand the whole app. What happens when you click → on the "Finish the Kanban" card:
CardItem takes dispatch with useBoardDispatch() and sends the action { type: 'card_moved', id: 'c3', column: 'doing' }. It changes nothing itself – it only reports what happened.boardReducer(old state, action). The reducer returns a new state: a new array of cards in which card c3 has column: 'doing'.BoardProvider re-renders with the new state and sends it down through BoardStateContext.Board reads the state with useBoard(), so it re-renders. It gives each column only its own cards (filter by column) – card c3 now lands in the In progress column.Every change takes the same path: adding a card (card_added), editing in the window (card_updated), deleting (card_deleted) and Undo (undo). Only who sends the action and what the reducer does with it differ.
For each milestone: what should come out of it, what to revise and how you can tell it's done. The exact brief with an example is next to each TODO in the code. Under the editor, finished milestones light up with ✅.
Card is one card, ColumnId and Priority list the allowed strings, and Action is a discriminated union from TypeScript 02 – a list of everything that can happen on the board. card_updated has the type Partial<Omit<Card, 'id'>>: Omit leaves id out of the card (it mustn't change) and Partial makes all the remaining properties optional – so you can change one property or several at once.switch branches: add a card at the end, change one card, remove a card. The rule "don't change, replace" from React basics 04 – every branch returns a new state object with a new array. This milestone has no button of its own, so the ✅ items under the editor try it directly: they call boardReducer with an action and look at the result. So don't rename the function.Board goes through the columns array with map and gives each column its filtered cards. The number in the header is cards.length – derived state, stored nowhere.onSubmit, put together a new card and send it with the card_added action. Revise forms from Advanced React 01 and trimming spaces with trim(). crypto.randomUUID() is a browser function that returns a random unique string – handy as an id. It's done when the card appears at the end of the column and the field is emptied.card_moved branch in the reducer (similar to card_updated, it changes only column) and the arrows in CardItem that send the action. index is the position of the card's column in the columns array, so the column on the left is columns[index - 1].BoardProvider holds the state and sends it through two contexts – the state separately from dispatch. Why separately is explained in Hooks 04 under "Separate state and actions": components that only send actions (say, the form) then don't re-render on every change of the cards.Modal: the cursor into the first field and Escape in an effect (Hooks 02 for the ref, Advanced React 05 for the portal and the accessible modal challenge), rendering into <body> and closing with a click on the backdrop. In CardModal: Save sends card_updated, Delete sends card_deleted. The window edits a draft (draft) – it goes to the reducer only after Save, so Cancel doesn't have to undo anything.cards, query and priority – no extra state. So that searching doesn't slow down typing, filter by the deferred copy of the text from useDeferredValue (Advanced React 04).usePersistentBoard hook has two jobs: load the cards from localStorage on start (the third parameter of useReducer – the box below) and save them after every change (an effect, Hooks 01). The inspiration is useLocalStorage from Hooks 05.BoardProvider and the hooks as a store from Advanced React 09 with persist – and compare how much code went away.The skeleton has already made several important decisions for you: where the data lives, what shape it has and where each piece of state belongs. The table explains them – the question in the left column, the reference solution's answer in the middle and why on the right. Each reason rests on an image from the course: a notebook (state), a bank account (reducer), a loudspeaker (Context), a camp (effect). In your own project, ask yourself the same questions – your answers may differ.
| Question | Reference solution | Why |
|---|---|---|
| Where do the cards live? | useReducer + Context | Many different actions on the same data (the bank account), and several components need it (the loudspeaker). State and dispatch in separate contexts. |
| Do I store the column in the card, or the cards in the columns? | column in the card, a flat array | Moving = changing one value, no copying between arrays. The card counts in the columns are simply computed. |
| Where is the search text? | Local useState in Board | A thing in one component's pocket. In an app with a router it would belong in the address (the wish list for a room). |
| A card edit in progress? | A local draft in the modal | Papers on the desk: it goes to the "bank" only after Save, so Cancel doesn't have to undo anything. |
| How does undo work? | A history in the reducer | The reducer is the only place where changes happen – you get the bank statement there with no extra work. |
| Persistence? | An effect syncs cards → localStorage | localStorage is the outside world, and that belongs in an effect (the camp); the reducer's lazy initialization loads it on start. |
The least obvious is the second question. The cards could be stored in two ways:
// ❌ cards inside columns: moving = remove from one array and add to another{ todo: [c3], doing: [c2], done: [c1] }// ✅ a flat array, the column is a property of the card: moving = changing one word[{ id: 'c1', title: '…', column: 'done' },{ id: 'c2', title: '…', column: 'doing' },{ id: 'c3', title: '…', column: 'todo' },]
With a flat array, moving is the same operation as editing (map and a change of column), you find a card by its id whatever its column, and searching goes through a single array. You get one column's cards with a simple filter.
What the board should do is set out by the milestones above and the TODO comments in the code. Try the reference solution in the "Reference solution" tab – it's saved to localStorage, so it survives a reload.
Medium and hard challenges unlock once you sign in. Like the whole course, they are free – just an e-mail, no password and no payment.