Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 713 Bytes

File metadata and controls

31 lines (21 loc) · 713 Bytes

useState vs use — demo

Live demo: https://programistka.github.io/usehook-demo/

A side-by-side comparison of two approaches to data fetching in React.

screenshot

What it shows

useState + useEffect use + Suspense + ErrorBoundary
React version ≤ 18 19
Loading state manual useState <Suspense fallback={...}>
Error state manual useState <ErrorBoundary>
Component size ~27 lines 3 lines
Component contains loading + error + happy path happy path only

Data source: JSONPlaceholder

Stack

  • React 19
  • TypeScript
  • Vite

Run

yarn dev