Data fetching, async cleanup, and subscriptions with useEffect
useEffect is a common place for data fetching and subscriptions, but async work must be cleaned up carefully to avoid races and leaks.
- Track loading and error states
- Avoid updating unmounted components
- Cleanup matters for listeners, sockets, and in-flight work
Data fetching, async cleanup, and subscriptions with useEffect