Practice ยท 3 of 3
Optimistic Update
Write optimisticApply(state, action) โ state is { items, pending: [] }. For action { type: "add", item }: append item AND record it in pending. For { type: "confirm", id }: remove id from pending (it's now real). For { type: "rollback", id }: remove the pending item from items too. Return the new state (non-mutating). Optimistic UI = show first, reconcile later.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Full-Stack Integration โ Practice