React Interview Questions and Answers
React interviews start with how components render and re-render: props versus state, keys, the virtual DOM and reconciliation, and what actually triggers an update. Interviewers then push into hooks (useState, useEffect, useMemo, useCallback, useRef), their rules, and the bugs they cause: stale closures, missing dependencies and effect loops.
Senior rounds move to design: state management trade-offs (context versus a store), data fetching and caching, code splitting, memoisation that really helps, accessibility and testing. Each question below has a worked answer with a short code example, so you can explain the why and not only the what.
Questions
- What is React and why was it created?
- What is the Virtual DOM and how does it work?
- What are the advantages of the Virtual DOM?
- What is React Fiber and how does it relate to reconciliation?
- Explain the reconciliation (diffing) algorithm in React.
- What is the difference between the Virtual DOM and the Shadow DOM?
- What is JSX and why is it used in React?
- How does JSX get transformed under the hood? (createElement / JSX transform)
- What is the difference between React.createElement and JSX?
- What is a React element vs a React component vs an instance?
- What are Functional Components and Class Components in React?
- What is the difference between Functional and Class Components?
- Can a functional component fully replace a class component? Are there exceptions?
- What are Props in React?
- What is State in React?
- What is the difference between Props and State?
- Why is immutability important in React?
- What are Controlled and Uncontrolled Components?
- When should you use Controlled vs Uncontrolled components?
- Why are keys important in React lists, and why is using the array index dangerous?
- What happens if you don't provide a key to a list item?
- What is a React Fragment and when should you use it?
- How do you use a Fragment with a key?
- What are the different patterns for conditional rendering in React?
- What is the difference between `&&` and ternary conditional rendering?
- How do you handle multiple conditions (more than two branches) in JSX?
- How are events handled in React compared to plain HTML/JavaScript?
- What is the SyntheticEvent in React?
- How does event delegation work in React?
- What is the difference between passing a function vs a string as an event handler?
- How do you pass arguments to event handlers in React?
- Why does React use camelCase event names like `onClick` instead of `onclick`?
- What is `React.createElement` signature and return value?
- What is `$$typeof` on a React element and why does it exist?
- Explain the difference between the classic and automatic JSX runtime.
- How does React render a component for the first time (mount)?
- What is the difference between the render phase and the commit phase?
- What does "React re-renders a component" actually mean?
- Why can't you use `if` statements or loops directly inside JSX?
- What can you put inside `{ }` in JSX?
- What are the rules of JSX?
- What is the difference between `className` and `class` in JSX?
- What is `children` in React and how does it work?
- What is prop drilling and why can it be a problem?
- What is lifting state up in React?
- What is one-way data flow in React?
- What does it mean that React components should be pure?
- What is Strict Mode in React?
- What is the difference between `null`, `false`, `undefined`, and an empty string in JSX rendering?
- How do you render lists in React?
- What is the purpose of `key` beyond removing warnings?
- Why does React not pass `key` and `ref` through props?
- How can changing a key reset component state?
- What is conditional component mounting versus hiding?
- What is the difference between an element type and an element instance?
- Why must component names start with an uppercase letter?
- How do you spread props in JSX?
- What is the difference between `defaultValue` and `value`?
- Why is a file input always uncontrolled?
- How does React handle boolean and custom attributes?
- What is the difference between `onChange` in React and HTML?
- How do `preventDefault` and `stopPropagation` differ?
- What are capture and bubble phases in React events?
- How do you handle keyboard events accessibly?
- What is a ref and how does it differ from state?
- What is `React.memo` and when should it be used?
- What is the difference between `useMemo` and `React.memo`?
- How can unnecessary re-renders happen in a React tree?
- What is `ReactDOM.createRoot` and how does it differ from `ReactDOM.render`?
- What is automatic batching in React 18?
- What is `useTransition` and how does it affect rendering priority?
- What is `useDeferredValue` and when might it help?
- What is an Error Boundary and why is it relevant to component trees?
- How does React handle an element type change during reconciliation?
- What are the most important Core React and JSX principles to remember?
- What is `useState` and how do you use it?
- What is lazy initialization in `useState`?
- What are functional updates in `useState`?
- How does state batching work in React 18?
- Can you update multiple state variables independently?
Related
- Node.js interview questions
- Angular interview questions
- System design interview questions
- Practice coding problems online
Frequently asked questions
What React topics are asked most in interviews?
Hooks and their pitfalls, how rendering and reconciliation work, state management (lifting state, context, stores), performance (memoisation, lists, code splitting) and testing components.
How do I prepare for a React interview?
Build one small app that uses every common hook, then read the answers here and explain each one out loud. Practise spotting a stale closure or an unnecessary re-render in a code snippet.
Are class components still asked?
Occasionally, mostly to compare the lifecycle with hooks. Focus on function components, but know how componentDidMount, componentDidUpdate and componentWillUnmount map to useEffect.