Skip to content

React Interview Questions

This lesson gathers frequently asked React interview questions with detailed answers — from JSX fundamentals through hooks, state management, and performance.

How to Use This Lesson

Explain answers in your own words with small code examples. Interviewers probe understanding through follow-ups, not memorized definitions.

// Be ready to explain this idiomatically
function Counter() {
  const [n, setN] = useState(0);
  return <button onClick={() => setN(c => c + 1)}>{n}</button>;
}

Explain state, re-render, and why functional update matters for rapid clicks.

Interview Topic Areas

Fundamentals → JSX, props, state, rendering
Hooks        → useState, useEffect, rules of hooks
Architecture → state management, data fetching
Performance  → memo, virtualization, profiling
Ecosystem    → Router, TypeScript, testing
  • Expect whiteboard coding for small components.
  • Know trade-offs: context vs Redux vs Zustand.
  • Explain virtual DOM at high level accurately.
  • Senior roles: system design and testing strategy.

Interview Quick Reference

Short answers to frequent questions.

Question Short Answer
What is React? UI library building component trees with declarative rendering
Props vs state? Props: read-only from parent. State: mutable, local
Rules of hooks? Top level only, same order, functions/hooks only
useEffect purpose? Sync component with external systems after render
Key prop purpose? Stable identity for list reconciliation
Context vs Redux? Context: built-in sharing; Redux: complex global client state

Conceptual Questions

Core conceptual questions interviewers ask.

  • Q: What happens when setState is called? A: React schedules re-render, runs component, reconciles DOM.
  • Q: Why keys in lists? A: Help reconciler match items across renders for correct updates.
  • Q: Controlled vs uncontrolled? A: React state drives value vs DOM holds value.
  • Q: When useEffect vs event handler? A: Effect for external sync on deps; handler for user actions.

Coding Questions

Applied questions often ask to build or fix small components.

// Q: Fix stale count in interval
// Wrong: setCount(count + 1) every second
// Right:
useEffect(() => {
  const id = setInterval(() => setCount(c => c + 1), 1000);
  return () => clearInterval(id);
}, []);

Common Mistakes

  • Memorizing answers without coding examples.
  • Outdated class component answers for hooks-first interviews.
  • Not preparing trade-off discussions.
  • Skipping testing and accessibility topics.

Key Takeaways

  • Interviewers test concepts and live coding.
  • Explain trade-offs, not just definitions.
  • Extended Q&A below covers common senior questions.
  • Practice building small components from scratch.

Pro Tip

For each answer, prepare a 30-second version and a 2-minute deep-dive — interviewers signal which they want.

Extended Interview Q&A

1. What is the virtual DOM and how does reconciliation work?

React builds a lightweight tree describing UI for each render. It diffs the new tree against the previous one and applies minimal updates to the real DOM. You write declarative JSX; React optimizes DOM operations.

2. Explain the rules of hooks and why they exist.

Hooks must be called at the top level in the same order every render so React can associate state with the correct component instance. Conditional or looped hook calls break that ordering and cause bugs.

3. What causes unnecessary re-renders and how do you fix them?

Parent re-renders, context changes, or new object/function props trigger child re-renders. Fix by colocating state, splitting context, using React.memo with stable props, or profiling to find real bottlenecks.

4. When would you choose Zustand over Redux?

Zustand suits smaller-to-medium global state with minimal boilerplate. Redux Toolkit fits larger teams needing middleware, strict patterns, DevTools, and complex slice architecture.

5. How does TanStack Query differ from storing API data in useState?

TanStack Query adds caching, deduplication, background refetch, stale-while-revalidate, and mutation invalidation — eliminating repetitive fetch/effect/loading boilerplate.

6. What is the difference between useMemo and useCallback?

useMemo caches a computed value; useCallback caches a function reference. Both accept dependency arrays and help optimization when paired with profiling and stable prop patterns.

7. How do error boundaries differ from try/catch?

Error boundaries catch render/lifecycle errors in child trees. try/catch handles imperative code like event handlers and async functions. Use both appropriately.

8. Explain code splitting in a React SPA.

Dynamic import() creates separate JS chunks loaded on demand. React.lazy and route-based splitting reduce initial bundle size and improve load performance.

9. What is prop drilling and how do you avoid it?

Passing props through many layers that don't use them. Avoid with composition (children), context for shared low-churn data, or state libraries for complex global client state.

10. Why is Create React App not recommended for new projects?

CRA is in maintenance mode with slower Webpack dev builds. The React team recommends Vite or meta-frameworks like Next.js for new applications with modern tooling.