Boss lesson · Unit 04
Structure an app
A small shop end to end: component boundaries, a home for each state, fewer wasted renders, the server, and tests.
What you practise
- Component boundaries, where each piece of state belongs, avoiding wasted renders, rendering on the server in outline, testing what the user sees
Try a question from this lesson
Pick one
Split this screen into components. Which split gives each component one job?
┌ Shop ──────────────────────┐
│ [ search box ] Cart: 2 │
│ Tea 4.00 [Add] │
│ Mug 9.00 [Add] │
└────────────────────────────┘Correct answer
Shop, Search, CartBadge, ProductList, ProductRow
Why
A component should do one thing, as a function should. The search box, the cart badge, the list and a single row each have a job and data of their own, so each becomes a component, and Shop arranges them.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Structure first, memo later
Most wasted renders are cured by structure. Keep state close to the components that use it. Let wrapper components take their content as children. Derive values instead of syncing them with effects. If one interaction is still slow, measure it, and only then wrap the slow component in memo.
11 more exercises in the app
- 1× match the pairs
- 5× multiple choice
- 2× type the answer
- 1× fill the blanks
- 1× order the lines
- 1× true or false
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.