Fetching data
Fetching data in React
Problem: Fetching in useEffect is clunky, verbose, and error prone.
Solution: Use one of these instead:
- React Server Components
- Tanstack Query
- Tanstack Router loaders
- React Router loaders
- Remix loaders
- RTK Query
- Apollo
- swr
Certains meta-frameworks like Next.js have built-in support for fetching data.
More details on Clean Architecture in React by Alex Kondov which explains why fetching data with useEffect is generally a bad idea.