Interview Prep9 min read

Top 20 React Interview Questions with Answers (2026)

Modern React interviews are hooks-first. Interviewers want to see that you understand state, effects, and why components re-render - not that you memorised lifecycle method names. Here's what comes up again and again, with the answers.

A laptop code editor showing component brackets, representing React frontend development

Hooks

How do useState and useEffect work?

useState adds local state to a function component and returns the value plus a setter. useEffect runs side effects after render and re-runs whenever a value in its dependency array changes; an empty array means 'run once on mount'.

What are the rules of hooks?

Call hooks only at the top level of a component or custom hook - never inside loops, conditions or nested functions - so React can reliably match each hook call across renders.

useMemo vs useCallback?

useMemo memoises a computed value; useCallback memoises a function's identity. Use them to skip expensive recomputation or to stop passing a fresh function to a memoised child on every render.

What is a custom hook?

A function whose name starts with 'use' that composes built-in hooks to share stateful logic between components - for example a useFetch hook that encapsulates loading, data and error state.

Core model

State vs props?

Props are read-only inputs passed from a parent; state is local, mutable data owned by the component and updated via its setter. Never mutate state directly - always set a new value so React re-renders.

What is the virtual DOM and reconciliation?

The virtual DOM is a lightweight in-memory representation of the UI. On each update React diffs the new tree against the previous one (reconciliation) and applies only the minimal real-DOM changes.

Why do lists need stable keys?

Keys let React match list items across renders. Stable, unique keys preserve state and DOM correctly; using the array index breaks on reordering or insertion and can attach the wrong state to the wrong item.

Controlled vs uncontrolled components?

A controlled input derives its value from state and updates via onChange; an uncontrolled input keeps its own state in the DOM, read via a ref. Controlled is preferred for validation and predictable data flow.

Performance

What causes unnecessary re-renders and how do you prevent them?

A component re-renders when its state or props change, or its parent re-renders. Prevent waste with React.memo for pure components, useCallback/useMemo to stabilise props, and by keeping state as local as possible.

What is the Context API good for, and its downside?

Context shares values (theme, auth) without prop-drilling. The downside: every consumer re-renders when the context value changes, so split contexts or memoise the value to limit re-renders.

The bottom line

Now go test yourself

React interviews reward a clear mental model over memorised APIs: understand how hooks work, why components re-render, and how React reconciles the virtual DOM, and you can reason your way through any question - even ones you haven't seen. Underneath it all, solid JavaScript is what makes your answers convincing.

Test your mental model before an interviewer does. Start a React quiz, work through the hooks and re-render questions, and let the explanations catch the subtle ones about dependency arrays and keys.

FAQs

Frequently asked questions

What React topics matter most for interviews?

Hooks (useState, useEffect, useMemo/useCallback), state vs props, the virtual DOM and keys, and re-render performance. Solid JavaScript underpins all of it.

Should I learn class components for React interviews?

Focus on function components and hooks, which dominate modern interviews. Know class-component basics only for legacy-codebase questions.

How do I prepare for a React interview fast?

Drill hooks and re-render questions as MCQs, and build one small component from scratch so you can talk through real decisions.

What is the useEffect dependency array and why does it matter?

The dependency array tells React when to re-run an effect: it runs after renders where a listed value changed. An empty array means 'run once on mount', and omitting it means 'run after every render' - a common source of bugs and interview questions.

Why shouldn't you use the array index as a key in React?

Keys let React match list items across renders. Using the index breaks when the list is reordered or items are inserted/removed, which can attach the wrong state to the wrong element. Use a stable, unique id instead.

What is the difference between state and props?

Props are read-only inputs passed from a parent; state is local, mutable data the component owns and updates via its setter. You never mutate state directly - you set a new value so React re-renders.

When should I use useMemo and useCallback?

Use useMemo to cache an expensive computed value and useCallback to keep a function's identity stable between renders - typically to prevent a memoised child from re-rendering. Don't add them everywhere; use them where a real performance problem exists.

What causes unnecessary re-renders in React?

A component re-renders when its state or props change or its parent re-renders. Prevent waste with React.memo, stable callbacks via useCallback, memoised values via useMemo, and by keeping state as local as possible.

Do I need strong JavaScript before learning React for interviews?

Yes - React sits on top of JavaScript. Closures, the event loop, this-binding and array methods all show up in React answers, so shore up your JavaScript fundamentals first.

Related quizzes

Put it into practice

Keep reading

Related articles

Browse all articles →

Test yourself in two minutes

Six adaptive questions, every answer explained by an AI tutor. Free.

▶ Start an AI quiz