React is still the most requested front-end library in job postings, which means React interview questions show up in almost every front-end, full-stack and UI engineer interview. This guide covers the top 20 ReactJS interview questions and answers, from fundamentals for freshers to hooks, performance and architecture questions for experienced React developers.
Use it to revise before a phone screen, a live coding round or a senior front-end interview. Each answer is short enough to say out loud and specific enough to show real hands-on experience.
React fundamentals
1. What is React and why is it popular?
React is an open-source JavaScript library for building user interfaces from reusable components. It is popular because of its declarative component model, one-way data flow, a huge ecosystem (Next.js, React Router, Redux, TanStack Query) and the ability to share skills across web and mobile with React Native.
2. What is the virtual DOM and how does reconciliation work?
The virtual DOM is an in-memory tree of React elements. When state changes, React renders a new tree, diffs it against the previous one (reconciliation) and applies only the minimal changes to the real DOM. Keys and element types guide the diffing algorithm, which keeps updates fast.
3. What is JSX?
JSX is a syntax extension that lets you write HTML-like markup inside JavaScript. A compiler such as Babel, SWC or esbuild turns it into React.createElement or the newer JSX runtime calls. JSX is optional, but it makes component trees far easier to read.
4. What is the difference between props and state?
Props are read-only inputs passed from a parent component. State is data a component owns and updates over time with useState or useReducer. Changing state triggers a re-render; a component should never mutate its own props.
5. Why are keys important in lists?
Keys give each list item a stable identity so React can match items between renders. Use a unique ID from your data, not the array index, when items can be reordered, inserted or deleted; otherwise you get wrong state, lost input focus and extra re-renders.
React hooks interview questions
6. What are React hooks and what are the rules of hooks?
Hooks are functions such as useState, useEffect, useContext, useRef, useMemo and useCallback that let function components use state and lifecycle features. The rules: call hooks only at the top level (not inside loops, conditions or nested functions) and only from React function components or custom hooks.
7. How does useEffect work and how do you avoid infinite loops?
useEffect runs side effects after render. The dependency array controls when it re-runs, and the returned cleanup function runs before the next effect and on unmount. Infinite loops usually come from setting state that is also a dependency, or from objects and functions recreated on every render; fix them with correct dependencies, useCallback/useMemo, or by moving logic out of the effect.
8. What is the difference between useMemo and useCallback?
useMemo caches a computed value; useCallback caches a function reference. Both take a dependency array. Use them for expensive calculations or to keep stable references for memoized children, not by default everywhere. The React Compiler can now apply much of this memoization automatically.
9. What is a custom hook?
A custom hook is a function whose name starts with use and that calls other hooks to package reusable stateful logic, for example useFetch, useDebounce or useLocalStorage. It shares logic, not state: each component that calls it gets its own state.
10. When would you use useRef?
useRef holds a mutable value that persists across renders without causing a re-render. Common uses are accessing a DOM node (focus, scroll, measuring), storing timer IDs, and keeping the previous value of a prop or state.
State management and data fetching
11. What is prop drilling and how do you avoid it?
Prop drilling is passing props through many layers that do not use them. Avoid it with component composition, the Context API for low-frequency global data (theme, auth, locale), or a state library such as Redux Toolkit, Zustand, Jotai or MobX for complex shared client state.
12. Context API vs. Redux: when do you use each?
Context is built in and fine for values that change rarely. Redux Toolkit adds a predictable store, middleware, DevTools and time-travel debugging, which suits large apps with complex, frequently changing shared state. For server data, many teams now use TanStack Query or RTK Query instead of storing API responses in global state.
13. How do you fetch data in React?
Options include fetch or Axios inside useEffect with loading and error state, data-fetching libraries like TanStack Query or SWR (caching, retries, background refresh), or server-side fetching with React Server Components and frameworks such as Next.js. Always handle loading, error and empty states and cancel stale requests.
14. What are controlled and uncontrolled components?
A controlled input gets its value from React 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. Form libraries like React Hook Form use uncontrolled inputs for performance.
Performance and advanced React
15. How do you optimize performance in a React application?
Measure first with the React DevTools Profiler. Then avoid unnecessary re-renders (React.memo, stable props, splitting state), virtualize long lists (react-window), code-split with React.lazy and Suspense, lazy-load images, debounce expensive handlers and keep bundle size down with tree shaking.
16. What are React Server Components?
Server Components render on the server and send a serialized result to the client, so their code and dependencies never ship to the browser. They can read databases or files directly. Client Components (marked with "use client") handle interactivity. Next.js App Router is the most common way to use them.
17. What is concurrent rendering in React 18 and later?
Concurrent rendering lets React prepare multiple versions of the UI and interrupt low-priority work. Features built on it include automatic batching, useTransition and startTransition for non-urgent updates, useDeferredValue, and streaming server rendering with Suspense.
18. What are error boundaries?
Error boundaries are components that catch JavaScript errors in their child tree during rendering and show a fallback UI instead of crashing the whole app. They are still written as class components (or with a library like react-error-boundary) and do not catch errors in event handlers or async code.
Testing and scenario questions
19. How do you test React components?
Use Jest or Vitest with React Testing Library for unit and integration tests that query the UI the way a user would (by role, label or text), mock API calls with MSW, and add end-to-end tests with Playwright or Cypress for critical user journeys.
20. Scenario: a page re-renders too often and feels slow. What do you do?
Profile it to find which components re-render and why. Common fixes: lift or split state so updates stay local, memoize expensive children, stop creating new object or function props on each render, move context values that change often into a separate provider, and virtualize large lists. Re-measure after each change.
How to prepare for a React interview
- Build or refresh a small project that uses hooks, routing, forms, API calls and tests, and be ready to walk through it.
- Practice live coding common components: a searchable list, a debounced input, a modal, pagination and a todo app with filters.
- Revise core JavaScript (closures, promises, async/await,
this, array methods) because React interviews test it too. - Know TypeScript basics with React: typing props, state, events and generic components.
- Prepare one story about a performance or state-management problem you solved.
For the language side, see our JavaScript interview questions, and for full-stack roles pair this with Node.js interview questions and the coding interview guide.
Frequently asked questions
What React topics are asked most in interviews?
Hooks (especially useEffect and useState), the virtual DOM, props vs. state, keys, state management, performance optimization and component testing come up most often.
What React interview questions are asked for experienced developers?
Senior React developers get questions on architecture, state management trade-offs, Server Components, concurrent rendering, performance profiling, micro-frontends and testing strategy.
Should I learn Next.js for React interviews?
For many full-stack and front-end roles, yes. Next.js is the most common React framework, so knowing routing, server rendering and Server Components is a strong advantage.
Got the interview? Make sure your resume tells the same story.
Interviewers read your resume right before they talk to you. HiReXL aligns it with the job description’s keywords so your experience and your answers match. HiReXL is built by 4As Consulting, a cloud and DevOps consulting firm. Looking for your next role? Submit your resume for open positions with PanAmerica Inc.


