Preparation · Frontend
React Interview Questions and Answers for Experienced Developers

React interviews at the mid and senior level rarely ask “what is JSX”. They ask why a component re-rendered, why an effect ran twice, and what you would do when a list of 5,000 rows gets slow. The questions below follow that pattern. Each answer is short on purpose: it is the version you could say in about a minute, with the reasoning an interviewer wants to hear.
Pair this with our 7-day technical interview prep plan if your round is next week.
Rendering and the virtual DOM
1. What does React do when state changes?
It re-runs the component function, builds a new tree of elements, compares it with the previous tree, and applies only the differences to the real DOM. The comparison is called reconciliation. Re-rendering a component does not mean the DOM changes. Most re-renders end with no DOM update at all.
2. Why do lists need keys?
Keys tell React which item is which between renders. With stable keys, React moves and updates the right elements. With array indexes as keys, inserting or reordering items can attach the wrong state to the wrong row, such as an input keeping text that belonged to a different item. Use an id from your data.
3. What triggers a re-render?
A state change in the component, a change in props from the parent, a change in a context value it reads, or the parent re-rendering. A child re-renders when its parent does, even with identical props, unless you wrap it in React.memo.
4. Does setState update the value immediately?
No. The update is queued, and the new value is available on the next render. React also batches several updates in one event into a single render. Since React 18 this batching applies to promises, timeouts and native events as well, not only React event handlers.
Hooks
5. How does useEffect work, and what is the dependency array for?
The effect runs after the render is painted. React compares each value in the dependency array with the last render and runs the effect again only if one changed. An empty array means once after mount. No array means after every render. The function you return is the cleanup, and it runs before the next effect and on unmount.
6. Why does my effect run twice in development?
In Strict Mode, React 18 and later mounts, unmounts and remounts each component once in development to expose effects that are not cleaned up properly. It does not happen in production. If the double run breaks your code, the effect is missing a cleanup (a subscription not closed, a request not aborted).
7. What is a stale closure?
A function that captured an old value. This is the classic case:
useEffect(() => {
const id = setInterval(() => {
setCount(count + 1); // always sees the count from the first render
}, 1000);
return () => clearInterval(id);
}, []);The counter sticks at 1. Fix it with the updater form, setCount(c => c + 1), or by adding count to the dependencies.
8. useRef versus useState?
Both survive re-renders. Changing a ref does not cause a render. Use state for values that appear on screen, and refs for DOM nodes, timers, or any value the UI does not read.
9. When should you use useMemo and useCallback?
When computing a value is expensive, or when you pass a function or object to a memoized child and a new reference on every render would defeat the memoization. They are not free, and wrapping everything adds noise. Measure first.
10. useReducer or useState?
useReducer fits when the next state depends on the previous one in several ways, when many fields change together, or when you want the update logic in one testable function. For a toggle or a single input, useState is simpler.
State management
11. When does state belong in context, and when does it not?
Context suits values that change rarely and are read in many places, such as theme, locale or the signed-in user. Every component that reads a context re-renders when its value changes, so frequently changing data in one big context causes needless renders. For that, split the context or use a dedicated state library.
12. What is lifting state up?
When two components need the same data, move the state to their closest common parent and pass it down. If you end up passing it through many layers, consider context or composition instead.
13. Controlled versus uncontrolled inputs?
A controlled input takes its value from state and updates through onChange, so React is the single source of truth. An uncontrolled input keeps its own value in the DOM and you read it with a ref when needed. Controlled is better for validation and live formatting, uncontrolled is lighter for simple forms.
14. Where should server data live?
Not in a global store by default. Libraries like TanStack Query or SWR handle caching, refetching, loading and error states for server data, and leave your own store for real client state. Many apps shrink their state code a lot after this split.
Performance
15. A list of 5,000 rows is slow. What do you do?
First find out what is slow with the React profiler. Common fixes: render only visible rows with windowing (react-window or similar), memoize row components, keep row state local instead of in the parent, and avoid creating new objects in props on every render. Pagination or server-side filtering sometimes removes the problem entirely.
16. What does React.memo do?
It skips re-rendering a component if its props are shallowly equal to the last render. It does not help when you pass a new object, array or function each time, which is why it often pairs with useMemo and useCallback.
17. How do you split a large bundle?
With React.lazy and Suspense for route or component level splitting, plus your bundler’s dynamic imports. Start with routes, since users rarely need every page at once.
Practical and design questions
18. Write a useDebounce hook.
function useDebounce(value, delay) {
const [debounced, setDebounced] = useState(value);
useEffect(() => {
const id = setTimeout(() => setDebounced(value), delay);
return () => clearTimeout(id);
}, [value, delay]);
return debounced;
}The cleanup cancels the previous timer whenever the value changes, so only the last value after the pause gets through. Interviewers often follow with “how would you use this for a search box?” (pass the debounced value to the request effect).
19. How do you catch errors in a component tree?
With an error boundary. It is still written as a class component using getDerivedStateFromError and componentDidCatch, or you can use a library that wraps one. Error boundaries catch errors during rendering, not in event handlers or async code, which you handle with try and catch.
20. How would you structure a large React app?
Group by feature, not by file type. Keep a feature’s components, hooks, API calls and tests together, and share only what is truly common. Keep components small, push logic into custom hooks, and keep server state, client state and URL state separate.
How to use this list
Do not memorise the wording. Pick five questions, answer them out loud without looking, then check yourself. If you cannot explain why something happens, open a small project and break it on purpose. Reproducing the stale closure from question 7 teaches more than reading about it ten times.
Also expect questions about your own work: a component you built, a performance problem you fixed, a bug that took you a day. Prepare two real examples from your projects.
For the rest of the loop—resume stories, system design, and a week-long schedule—see our guides on behavioral interview questions, system design interview questions, and preparing in 7 days.
Rehearse React answers out loud with resume context
Explore Qevra AIFrequently asked questions
Is the virtual DOM still a thing in React interviews?
Yes, as a concept. You should explain reconciliation and keys even if you never think about it day to day.
Do I need to know class components?
Know the lifecycle methods well enough to read old code and to explain error boundaries. New code is written with function components and hooks.
Do I need to know Next.js or server components?
If the job description mentions it, yes. Learn what runs on the server, what runs in the browser, and why data fetching moved server-side.
How should I practise coding rounds?
Build small things from scratch with a timer: a todo list, a debounced search, an infinite scroll, a modal with focus handling.
Qevra AI is a desktop app that transcribes interview questions and shows answer outlines based on your resume and the job description. It works well for rehearsing these questions out loud. Check the rules of any real interview before using an assistant in it.
Ready to practise React interview answers?
Explore Qevra AI