HomeChallengesRepsProblemsLeaderboardTake a challenge

Callbacks with types

Each card keeps its own copy of the status, so the kitchen never finds out an order moved, and "delivered" wraps round to "pending". Move the state up, give the card a typed onAdvance callback, stop at delivered, and type the search box’s change event.

Advanced10 min on the clock5 graded checks · 100 pointsTyped React
Graded by running your code against real cases.

What you build

  • Give OrderCard an onAdvance: (id: number, next: OrderStatus) => void prop
  • Make nextStatus return null after delivered, and hide the button then
  • Make advanceOrder return a new array instead of editing one
  • Keep the orders’ state only in the parent
  • Type the change event as ChangeEvent<HTMLInputElement>

Done means

A typed callback, a flow that stops at delivered, immutable updates, state only in the parent, and a typed event.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. onAdvance is a typed function prop+20Lifting state up
  2. Refuses onAdvance(1, "done")+15Union types and narrowing
  3. The change event is typed, with no any+15TypeScript basics
  4. pending → cooking → ready → delivered, then stop+30Lifting state up
  5. State lives only in the parent+20Lifting state up

What it teaches

The rest of Typed React