Skip to content

React Hooks Advanced Patterns

Master React Hooks Advanced Patterns with 224 free flashcards. Study using spaced repetition and focus mode for effective learning in Programming.

🎓 224 cards ⏱️ ~112 min Advanced
Study Full Deck →
Share: 𝕏 Twitter LinkedIn WhatsApp

🎯 What You'll Learn

Preview Questions

12 shown

Why does useEffect run twice in dev?

Show ▼

Strict Mode mounts → unmounts → remounts to catch bugs from missing cleanups. Production runs effects once per mount.

Common cause of infinite useEffect loop?

Show ▼

Updating state inside the effect with a dep that changes when state updates. Memoize the value or remove from deps if it doesn't need to trigger.

How does useCallback help?

Show ▼

Returns the same function reference unless deps change — avoids re-rendering children that take it as a prop and use memo().

useMemo vs useCallback?

Show ▼

useMemo(f, d): memoizes a value (the result of f()).
useCallback(f, d): memoizes the function itself. Equivalent to useMemo(() => f, d).

useRef common uses?

Show ▼

Mutable container that doesn't trigger re-render: DOM nodes, timers, latest-value pattern, instance variables.

Pattern to read 'latest' state without stale closures?

Show ▼

const ref = useRef(state);
useEffect(() => { ref.current = state; });
// use ref.current inside callbacks

useReducer vs useState?

Show ▼

Use useReducer when next state depends on previous state, when state shape is complex, or when actions describe intent better than setters.

Lift state up or use Context?

Show ▼

Lift up if 2-3 components share state. Context for app-wide state or theme/auth. Don't use Context for high-frequency updates — re-renders all consumers.

Why Context can cause perf issues?

Show ▼

Every consumer re-renders when context value changes. Split contexts by domain, memoize value, or use selector libraries (useContextSelector).

Custom hook naming rule?

Show ▼

Must start with use — React linter and DevTools rely on this.

Rules of Hooks (two)?

Show ▼

1) Call at the top level of a component or another hook — not inside loops/conditions.
2) Call from React functions only — components or other hooks.

How to debounce a value with hooks?

Show ▼

function useDebounced(v, ms=300) {
const [d, setD] = useState(v);
useEffect(() => {
const t = setTimeout(() => setD(v), ms);
return () => clearTimeout(t);
}, [v, ms]);
return d;
}

🎓 Start studying React Hooks Advanced Patterns

🎮 Study Modes Available

🔄

Flashcards

Flip to reveal

🧠

Focus Mode

Spaced repetition

Multiple Choice

Test your knowledge

⌨️

Type Answer

Active recall

📚

Learn Mode

Multi-round mastery

🎯

Match Game

Memory challenge

Related Topics in Programming

📖 Learning Resources