Why components render, how React batches updates, where stale values come from, how keys decide identity, and when memo, useMemo and useCallback actually help. Every lesson runs a real React component step by step.
React · intermediate · 9 lessons · 1 h 5 min · free
What you'll learn
Predict which components render, and why
Avoid stale closures in timers and callbacks
Reset or keep state on purpose with keys
Use memo, useMemo and useCallback where they pay off
Structure app state with a reducer and context
Before you start
React Fundamentals
Lessons
How Rendering Works
Renders, batching, stale closures, keys and derived state.
When Does a Component Render?: Click once and count the renders: the parent, and every child with it. See why that is cheap, and what actually reaches the page.
Batching: Many Updates, One Render: Three setters in one click lead to one render, not three. Watch the queue fill up and empty in a single pass.
Stale Closures: Click twice, and two timers add one each. Why does the count only reach 1? Each timer remembers the count from its own render.
Keys and Component Identity: Type a message to Ada, then switch to Linus. A key makes React start a fresh Chat so the draft is not sent to the wrong person.
memo: Skipping a Re-render: Wrap a component in memo and React skips it when its props have not changed. Compare it with an ordinary child.
useMemo: Caching a Calculation: Keep a slow calculation from running on every render. Toggle the theme and it is skipped; change n and it runs.
useCallback with memo: Give a memo child the same function every render with useCallback, and typing no longer re-renders the Save button.
App State
A reducer and context as a small app-wide store.
Reducer + Context: an App Store: Keep app state in a reducer at the top and share both the state and dispatch through context. Any component can read or update it.
Related courses
React Fundamentals: What React really does when a component renders, when state changes and when an effect runs. Every lesson runs a real React component and shows its state, its renders and the page at each step. (21 lessons, 2 h 29 min)