React Interview Questions and Answers
React questions test whether you understand how components render and update, not just whether you can build a form. Interns are asked about props, state and hooks; mid-level and senior candidates are asked why a component re-renders, how to prevent wasted work and how rendering strategies affect performance and SEO.
Usually asked in frontend and full stack interviews, from intern / fresher to senior (5+ years).
Intern / Fresher
- Q1Intern / FresherWhat is the virtual DOM in React and how does it work?
The virtual DOM is a lightweight JavaScript copy of the UI that React compares with the previous version after each update, so it only changes the parts of the real DOM that actually differ.
- Q2Intern / FresherWhat is the difference between props and state in React?
Props are read-only inputs passed from a parent component, while state is data a component owns and can change over time, which triggers a re-render when updated.
Junior (0-2 years)
- Q1Junior (0-2 years)What are React hooks and what are the rules of hooks?
Hooks are functions such as useState and useEffect that let function components use state, lifecycle behaviour and other React features; they must be called at the top level of a component or custom hook, never inside loops, conditions or nested functions.
- Q2Junior (0-2 years)How does useEffect work in React and what is the dependency array?
useEffect runs a function after the component renders; the dependency array tells React when to re-run it: with no array it runs after every render, with an empty array only after the first, and with values only when those values change.
- Q3Junior (0-2 years)Why do we need keys in React lists?
Keys give each list item a stable identity so React can match items between renders and correctly add, remove or reorder them without recreating or mixing up their state.
- Q4Junior (0-2 years)What is the difference between controlled and uncontrolled components in React?
A controlled component keeps the input's value in React state and updates it through onChange, while an uncontrolled component lets the DOM hold the value and you read it with a ref when needed.
- Q5Junior (0-2 years)What is prop drilling and how do you avoid it in React?
Prop drilling is passing props through several layers of components that do not use them just to reach a deeply nested child; you avoid it with composition, the Context API or a state management library.
Mid-level (2-5 years)
- Q1Mid-level (2-5 years)What is the difference between useMemo and useCallback in React?
useMemo caches the result of a calculation, while useCallback caches a function definition; both only recompute when their dependencies change.
- Q2Mid-level (2-5 years)What is the difference between useRef and useState in React?
Updating state triggers a re-render, while changing a ref's .current value does not; use state for data shown on screen and refs for DOM access or values that must persist without causing renders.
- Q3Mid-level (2-5 years)What is the difference between SSR, SSG and CSR in React?
CSR renders in the browser after JavaScript loads, SSR renders the HTML on the server for each request, and SSG renders the HTML once at build time; SSR and SSG give crawlers and users content faster, which helps SEO.
Senior (5+ years)
- Q1Senior (5+ years)Why does a React component re-render and how do you prevent unnecessary re-renders?
A component re-renders when its state changes, its parent re-renders, or a context it consumes changes; you prevent wasted renders by moving state down, using React.memo, and keeping props referentially stable.
- Q2Senior (5+ years)How do you optimize performance in a React application?
Measure first with the Profiler and Lighthouse, then reduce unnecessary renders, split code with lazy loading, virtualise long lists, and optimise images and bundle size.