BookNest's state now has two kinds of problems. The cart lives in a React 7,897 context, so every screen that reads it re-renders on every change. And the catalog is a JSON file bundled into the app, while a real shop's catalog lives on a server, arrives slowly, changes without warning and is unavailable in a tunnel. This section splits the two concerns the way most React Native 36,878 apps now do: Zustand 58,763 (5.0.15) holds client state such as the cart, and TanStack Query 79,069 (5.103.2) fetches, caches and refreshes server state. A short Node server with no dependencies, api/server.mjs, serves 60 books at http://10.0.2.2:8150, the address of the development machine as the emulator sees it, and waits 800 ms before each reply so that loading states are visible.
MENU
Query and Zustand
State and Data with TanStack Query and Zustand