Effects & Data Fetching in React
Synchronize React components with external systems using effects and refs, and fetch, cache and mutate server data without race conditions.
4 objectives 6 steps about 130 min
Learn it step by step
Read the lessons in order, try the practice checks, then prove the skill with the knowledge check.
This skill page is a public outline. Its lessons and knowledge check appear here as subject-matter experts approve them.
Learning objectives
- Decide when an effect is needed versus computing during render or handling logic in an event handler, and write effects with complete dependencies and cleanup.
- Extract reusable logic into custom hooks and use refs for DOM access and values that must not trigger re-renders.
- Fetch server data in components without race conditions, rendering loading, error and empty states and recovering with an error boundary.
- Manage server state with a query cache such as TanStack Query: query keys, stale times, invalidation after mutations and optimistic updates with rollback.
Lesson plan
6 steps, about 130 min · 5 of 5 lessons available so far
- Effects as Synchronization, Not Lifecycle Concept · 20 min
- Deleting Effects You Do Not Need Worked example · 20 min
- Refs and Custom Hooks Worked example · 20 min
- Fetching Data Safely Inside Components Worked example · 25 min
- Lab: Server State with a Query Cache Lab · 30 min
- Check: Effect and Fetching Bug Hunt Knowledge check · 8 questions
Practise it
Add a book-search page backed by a public API: a custom useDebouncedValue hook, a query cache with deliberate stale times, an error boundary with retry, and an optimistic 'add to reading list' mutation that rolls back when the request fails.
Build it from scratch
Practice builds that exercise this skill by re-creating a real technology.
- Build your own ReactIntermediate · 6–12 h
References
Hard prerequisites
Unlocks
Nothing depends on this skill yet.
On these roadmaps
Progress and evidence for this skill are shared across all of them.