0
Challenge · 54Routing & Data
CRUD Operations
Coreused in ~95% of apps
Every app that stores anything is really just four verbs in a trench coat: Create, Read, Update, Delete. Learn how each one maps to an HTTP method and how to keep your on-screen list in sync after the server says yes, and you can build the data layer of almost any product.
Core idea. CRUD is Create / Read / Update / Delete; over a REST API those map to POST / GET / PUT-or-PATCH / DELETE, and after a successful mutation you update local state immutably (or refetch) so the UI reflects the new server truth.
poke it, drag it,
try to break it
try to break it
no slides here.
you drive.
you drive.
Playground, this isn't a screenshot
CRUD ↔ HTTP verb
POSTCreateGETReadPATCHUpdateDELETEDelete
local list (React state)2 items
#1Ship the feed
#2Review PRs
network — request / response
Add, edit, or delete an item. Watch the HTTP verb fire, then the local list update after the response.
Each mutation waits for the server's response, then updates the local list immutably (map / filter / spread) — no full refetch. Showing the change before the response is optimistic UI (#71).
↑ play a little first, then dig in