React Hooks Interview Questions & Answers
Short answer
The hooks below come up in almost every React interview. Here are clear, interview-ready answers to the most common ones — with the reasoning interviewers actually want to hear.
How does useState work and why is state not updated immediately?
useState returns [value, setter]. The setter schedules a re-render; within the current render the value is a fixed snapshot, so reading it right after setting gives the old value. When the next state depends on the previous, use the functional updater: setCount(c => c + 1).
What is the dependency array in useEffect?
It controls when the effect re-runs. Omitted = every render, [] = mount only, [a, b] = when a or b change. Every reactive value the effect reads must be listed, or you get stale-closure bugs.
useMemo vs useCallback — what's the difference?
useMemo caches a computed value; useCallback caches a function. Their real job is referential stability — keeping props stable for a React.memo child or an effect dependency. Don't sprinkle them everywhere; they only help in those cases.
const total = useMemo(() => items.reduce((s,i)=>s+i.price,0), [items]);
const onSelect = useCallback(id => setSel(id), []);Frequently asked questions
- How many hooks does React have?
- React ships about a dozen built-in hooks (useState, useEffect, useContext, useReducer, useRef, useMemo, useCallback, useLayoutEffect, useId, useTransition, useDeferredValue, useSyncExternalStore). You can also build custom hooks.
- Can you call hooks conditionally?
- No. Hooks must be called at the top level in the same order every render, because React tracks them by call order.
This is 1 of 75+ questions in the React Interview Kit
Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.
⚡ Get the React Interview Kit → ₹399