Build a data-fetching hook that fails well: a status union instead of booleans, retries only for errors worth retrying, exponential backoff with jitter, Retry-After, cancellation on unmount, and a clear budget for giving up.
The useEffect + fetch + useState hook from most blog posts works on a fast connection with a healthy server. Production is different: mobile networks drop, servers return 503 during deploys, rate limits return 429, and users navigate away mid-request.
A production-grade fetching hook needs to:
loading/error booleans: idle | loading | success | error. Booleans allow impossible combinations.Retry-After when the server says when to come back.In real apps you'll often get this from a query library (TanStack Query retries 3 times with exponential backoff by default). Building it once teaches you which settings to change and why. And the same logic belongs in non-React code too: API clients, service workers, and upload queues.