React is a JavaScript library for building user interfaces out of small, reusable parts called components. Meta first released it, and since February 2026 it has a new home in the React Foundation under the Linux Foundation. So when a job post asks for React, it means you can build and debug screens made of components, state and hooks.
Most React interview questions fall into a small set of themes. Interviewers ask about JSX and components first, then hooks such as useState and useEffect, then how React renders and how to make it fast. Senior rounds add React 19 topics like Actions, Server Components and the React Compiler, plus testing and one or two live coding tasks.
The 200 questions in this post follow that same order. Each one has a short answer you can say out loud in under a minute, with code where code makes the point faster. After the questions, you will also find a seven-day prep plan and answers to common questions about React interviews.

What React Interviewers Check at Each Level
Interview rounds change a lot with experience. For example, a fresher round in Bengaluru or Pune often stays on JSX, props, state and simple hooks. By contrast, a senior round spends more time on rendering cost, data fetching and how you would design a shared component library.
Also, the current version matters. React 19.3 came out on September 9, 2026 with a stable ViewTransition component and Fragment refs, so recent answers should not stop at React 18.
| Level | What gets asked most | Usual round format |
|---|---|---|
| Fresher (0 to 1 year) | JSX, props, state, lists, events, useState, useEffect | MCQ test, then one live round |
| Mid level (2 to 4 years) | Hooks rules, memo, context, forms, data fetching, testing | Live coding plus a theory round |
| Senior (5+ years) | Rendering cost, Suspense, Server Components, app design | System design plus code review |
| Lead | Team patterns, migration plans, build tools, code quality | Design talk and a manager round |
So, read the whole list once, then go back to the parts your level needs most.
React Basics and JSX Questions
1. What is React?
React is a JavaScript library for building user interfaces. You describe what the screen should look like for a given state, and React updates the page when that state changes. Also, React handles only the view layer, so routing and data fetching come from other tools or a framework.
2. Is React a library or a framework?
React is a library. However, it is often used inside frameworks such as Next.js or React Router, which add routing, data loading and server rendering on top. In an interview, say that React itself gives you components and hooks, and a framework gives you the rest of the app structure.
3. What is JSX?
JSX is a syntax that lets you write HTML-like markup inside JavaScript. For example, <h1>Hello</h1> in a component is turned into a function call that creates a React element. Browsers cannot read JSX directly, so a tool like Babel, SWC or esbuild compiles it first.
4. Why must JSX return a single root element?
A component returns one value, so JSX needs one parent. If you want two siblings with no extra div, wrap them in a Fragment: <>...</>. As a result, the DOM stays clean and your layout CSS is not broken by a wrapper you did not need.
5. What is a React element?
A React element is a plain object that describes what to show, such as a tag name, props and children. Elements are cheap to create and cannot be changed after you make them. React reads them and decides what to change in the real DOM.
6. What is the difference between an element and a component?
A component is a function (or class) that returns elements. An element is the object that a component call produces. So Button is a component, while <Button /> creates an element that tells React to render that component.
7. How do you embed a JavaScript value in JSX?
Put it inside curly braces. For example, <p>{user.name}</p> shows the name, and <img src={photoUrl} /> passes a variable as an attribute. You can place any expression inside the braces, but not a statement such as if or for.
8. Why does JSX use className and htmlFor?
class and for are reserved words in JavaScript. So JSX uses className for CSS classes and htmlFor on labels. Also, most attributes are written in camelCase, such as onClick and tabIndex.
9. How do you write inline styles in JSX?
Pass an object to the style prop, with camelCase names and string or number values. For example, <div style={{ backgroundColor: 'teal', padding: 8 }} /> sets two styles. React adds px to most plain numbers for you.
10. How do you render content conditionally?
Use plain JavaScript. For instance, use if before the return, the ?: operator inside JSX, or && for show-or-hide cases. Be careful with && and numbers, because {count && <List />} renders 0 when the count is zero.
11. How do you render a list?
Call map() on an array and return JSX for each item. Each item also needs a stable key prop, usually an ID from your data:
<ul>{todos.map(t => <li key={t.id}>{t.text}</li>)}</ul>
12. Why are keys needed in lists, and why not use the index?
Keys tell React which item is which between renders. So when you add, remove or sort items, React can keep the right state with the right row. Index keys break when the order changes, because the state of row 2 can end up on a different item.
13. Does a key need to be unique across the whole app?
No. A key only needs to be unique among siblings in the same list. Two different lists on the same page can reuse the same IDs. Also, keys are not passed to the component as a prop, so pass the ID again under another name if the child needs it.
14. What is the virtual DOM?
The virtual DOM is the tree of React elements kept in memory. When state changes, React builds a new tree and compares it with the old one. Then it applies only the needed changes to the real DOM, which is slower to touch.
15. What is reconciliation?
Reconciliation is the process React uses to compare the new element tree with the previous one. If an element type changes, for example from div to span, React rebuilds that subtree. If the type stays the same, React keeps the DOM node and updates only the changed attributes.
16. What is React Fiber?
Fiber is the engine inside React that does reconciliation since React 16. It splits rendering into small units of work. So React can pause, resume or drop work, which is what makes transitions and Suspense possible.
17. What does ReactDOM do?
The react-dom package connects React to the browser DOM. For example, createRoot from react-dom/client mounts your app, and react-dom/server renders it to HTML. React Native uses a different renderer for the same component model.
18. How do you mount a React app in React 19?
Use createRoot and call render on it:
import { createRoot } from 'react-dom/client';
createRoot(document.getElementById('root')).render(<App />);
Also note that ReactDOM.render was removed in React 19, so older tutorials will fail.
19. What is one-way data flow?
Data in React moves down from parent to child through props. A child cannot change its parent’s data directly. Instead, the parent passes a function, and the child calls it to ask for a change. As a result, it is easier to trace where a value came from.
20. What is a Fragment and when do you need the long form?
A Fragment groups children without adding a DOM node. The short form <>...</> cannot take props. So when you render fragments in a list, use <Fragment key={id}> from React, because the key has to go somewhere.
21. What is StrictMode?
<StrictMode> is a development-only wrapper that finds bugs early. For example, it renders components twice and runs effects twice to expose impure code and missing cleanup. It has no effect in production builds.
22. Why do my effects run twice in development?
StrictMode mounts, unmounts and mounts your component again in development. So any effect without a proper cleanup shows its bug right away. The fix is to return a cleanup function from the effect, not to remove StrictMode.
23. What are pure components in the React sense?
A pure component returns the same JSX for the same props, state and context. It also does not change outside variables while rendering. React’s docs ask for purity, because React may render a component more than once or pause it halfway.
24. Can a component return null?
Yes. Returning null tells React to render nothing for that component. However, the component still runs, and its hooks still count, so you cannot skip hooks with an early return placed before them.
25. How do you comment inside JSX?
Wrap a JavaScript comment in braces: {/* note */}. Plain HTML comments do not work in JSX. Outside the markup, normal // and /* */ comments work as usual.
Components, Props and State Questions
26. What are props?
Props are the inputs a parent passes to a child component, like arguments to a function. For example, <Avatar size={40} /> gives Avatar a size prop. Props are read-only, so a child should never change them.
27. What is state?
State is data a component remembers between renders, such as a form value or an open menu. When you update state with its setter, React renders the component again. Unlike props, state belongs to the component that declares it.
28. What is the difference between props and state?
Props come from the parent and cannot be changed by the child. State is owned by the component and changes over time through a setter. So a good rule is this: if a value can be computed from props, it should not be state.
29. What is the children prop?
children holds whatever you put between a component’s opening and closing tags. For example, <Card><p>Hi</p></Card> gives Card the paragraph as children. This lets you build wrappers like modals and layouts.
30. How do you set default values for props?
Use default values in the function’s parameters, for example function Button({ size = 'md' }). In React 19, defaultProps no longer works on function components. Class components still support it.
31. What happened to propTypes?
React 19 silently ignores propTypes checks on function components. So teams now use TypeScript for prop types. If an older codebase relies on propTypes, the checks stop running after the upgrade without any warning.
32. What is lifting state up?
When two siblings need the same data, you move that state to their closest shared parent. Then the parent passes the value down as props, along with a setter. As a result, both children always show the same value.
33. What is prop drilling, and how do you avoid it?
Prop drilling means passing a prop through many layers that do not use it. You can avoid it with context, by passing components as children, or with a state library. However, two or three layers of props are fine and often clearer than context.
34. What are controlled and uncontrolled components?
In a controlled input, React state holds the value and onChange updates it. In an uncontrolled input, the DOM holds the value and you read it with a ref or from FormData on submit. Controlled inputs make live checks easy, while uncontrolled ones need less code.
35. What is a class component?
A class component extends React.Component and has a render method. It keeps data in this.state and uses lifecycle methods such as componentDidMount. Classes still work in React 19, but new code uses function components and hooks.
36. Name the main class lifecycle methods.
The common ones are constructor, render, componentDidMount, componentDidUpdate, componentWillUnmount and shouldComponentUpdate. Also, getDerivedStateFromError and componentDidCatch are what error boundaries use. The old componentWillMount style methods are marked UNSAFE.
37. How do hooks map to class lifecycles?
useEffect with an empty dependency array runs after the first mount, like componentDidMount. Its cleanup runs on unmount. An effect with dependencies reruns after updates to those values, which covers most componentDidUpdate cases.
38. Why is state update asynchronous?
React batches state updates and applies them on the next render. So right after setCount(count + 1), the count variable in your current function still holds the old value. Read the new value in the next render, not on the next line.
39. What is an updater function in setState?
You pass a function instead of a value: setCount(c => c + 1). React gives it the latest pending state. This matters when you queue several updates in one event. Three calls with count + 1 add only one, while three updater calls add three.
40. What is automatic batching?
Since React 18, React groups several state updates into one render, even inside timeouts, async callbacks and native events. So two setState calls in a fetch callback cause one render. If you truly need an update to apply at once, use flushSync from react-dom.
41. Why should you not mutate state directly?
React compares the old and new state by reference. If you change an object in place and pass the same object back, React may skip the render. Instead, create a new copy: setUser({ ...user, name: 'Asha' }).
42. How do you update an array in state?
Return a new array. For example, use [...items, newItem] to add, filter to remove and map to change one item. Avoid push, splice and sort on the state array itself, or copy it first with [...items] or use toSorted().
43. How do you update nested objects in state?
Copy each level you change. For instance, setForm({ ...form, address: { ...form.address, city: 'Pune' } }). For deep data, many teams use Immer, which lets you write mutating code that produces a new object.
44. What is derived state, and why avoid it?
Derived state is a value you could compute from props or other state, stored as its own state. It tends to go out of sync. So compute it during render instead, for example const total = items.reduce(...), and wrap it in useMemo only if it is slow.
45. How do you reset a component’s state?
Give it a different key. When the key changes, React throws away the old instance and mounts a fresh one with fresh state. For example, <Profile key={userId} /> resets the form when you switch users.
46. Does state survive when a component moves in the tree?
State is tied to the component’s position in the tree. If the same component type stays at the same position, React keeps its state. However, if you render it in a different spot or wrap it in a new element type, the state resets.
47. What is composition, and why does React favour it over inheritance?
Composition means building bigger components out of smaller ones and passing parts in as props or children. React’s docs recommend it over class inheritance. For example, a Dialog can take a footer prop with any buttons you like.
48. What is a higher-order component?
A higher-order component (HOC) is a function that takes a component and returns a new one with extra behaviour, such as withAuth(Page). HOCs were common before hooks. Today, a custom hook usually does the same job with less nesting.
49. What is the render props pattern?
A render prop is a prop that takes a function returning JSX. The component calls that function with its data, for example <Mouse render={pos => <Dot at={pos} />} />. Like HOCs, this pattern is now mostly replaced by custom hooks.
50. What is a pure function component compared with React.memo?
A pure function component is about how you write it. React.memo is a wrapper that skips re-rendering when props are shallowly equal. So a component can be pure without memo, and memo only helps when the parent renders often with the same props.
Read also: 200 Angular Interview Questions With Short Answers
React Interview Questions on Hooks
51. What are hooks?
Hooks are functions whose names begin with use that let function components keep state, run side effects and read context. They arrived in React 16.8. Before that, you needed a class for any stateful logic.
52. What are the rules of hooks?
Call hooks only at the top level of a component or a custom hook, never inside loops, conditions or nested functions. Also, call them only from React functions, not from plain JavaScript helpers. React tracks hooks by call order, so a skipped call shifts every hook after it.
53. How does useState work?
useState(initial) returns a pair: the current value and a setter. For example, const [open, setOpen] = useState(false). Calling the setter with a new value schedules a render, and the component then reads the new value.
54. What is lazy initial state?
If the starting value is costly to compute, pass a function: useState(() => loadDraft()). React calls it only on the first render. By contrast, useState(loadDraft()) runs loadDraft on every render and throws the result away.
55. What does useEffect do?
useEffect runs code after React has updated the screen. You use it to sync with things outside React, such as a chat socket, a timer or a browser API. It takes a setup function and a dependency array that controls when it runs again.
56. Explain the dependency array options.
With no array, the effect runs after every render. With [], it runs once after mount and cleans up on unmount. With [a, b], it runs after mount and again whenever a or b changes, compared with Object.is.
57. What is an effect cleanup function?
It is the function you return from an effect. React calls it before the effect runs again and when the component unmounts. For example, a socket effect returns () => socket.close(), so you never have two open connections.
58. When should you not use an effect?
You do not need an effect to compute values from props or state, or to handle a user event. For example, filter a list during render and call the API inside the click handler. Effects are for syncing with outside systems, so extra effects usually mean extra renders and bugs.
59. What is the difference between useEffect and useLayoutEffect?
useLayoutEffect runs after React changes the DOM but before the browser paints. So you can measure an element and fix its position with no flicker. However, it blocks painting, so use useEffect unless you see a visual jump.
60. What is useInsertionEffect?
useInsertionEffect runs before any layout effects. It exists for CSS-in-JS library authors who need to add style tags before layout is read. App code almost never needs it.
61. How does useContext work?
First create a context with createContext(defaultValue). Then provide a value higher in the tree and read it with useContext(MyContext) in any child. When the provided value changes, every component that reads that context renders again.
62. How do you provide context in React 19?
In React 19 you can render the context itself as the provider:
<ThemeContext value="dark">
<Page />
</ThemeContext>
The older <ThemeContext.Provider> still works. Also, since React 19.3, Server Components can render a context from a client module this way, with no wrapper.
63. What is the downside of context?
Every consumer renders again when the context value changes. So if you pass a new object on every render, all consumers render every time. Split big contexts by topic, and wrap the value in useMemo when it is an object.
64. What does useReducer do?
useReducer(reducer, initialState) returns the state and a dispatch function. You send actions like { type: 'added', id }, and the reducer returns the next state. It works well when many event handlers change the same state in related ways.
65. When do you pick useReducer over useState?
Pick useReducer when the next state depends on the previous one in complex ways, or when several values change together. For instance, a shopping cart with add, remove and coupon actions reads better as a reducer. For a single toggle, useState is shorter.
66. What does useRef return?
useRef(initial) returns an object with a current property that lasts for the whole life of the component. Changing ref.current does not cause a render. So refs hold DOM nodes, timer IDs and other values that should not trigger updates.
67. How do you focus an input with a ref?
Attach the ref and call focus in a handler or effect:
const inputRef = useRef(null);
<input ref={inputRef} />
<button onClick={() => inputRef.current.focus()}>Edit</button>
68. Why does useRef need an argument now?
In React 19’s TypeScript types, useRef requires an argument. So write useRef(null) or useRef(undefined). This makes refs behave the same way as createContext, which also needs a starting value.
69. What is useMemo?
useMemo(fn, deps) caches the result of a calculation between renders. React runs fn again only when a dependency changes. For example, use it to avoid sorting 10,000 rows on every keystroke.
70. What is useCallback?
useCallback(fn, deps) caches a function itself, not its result. It matters when you pass the function to a child wrapped in memo or use it as an effect dependency. Otherwise a new function on each render breaks those checks.
71. Do you still need useMemo and useCallback with the React Compiler?
Mostly not for new code. The React Compiler adds memoization at build time, and React Compiler 1.0 shipped as stable in October last year. However, you can keep manual hooks where you need exact control, such as a value used as an effect dependency.
72. What is a custom hook?
A custom hook is your own function that starts with use and calls other hooks. It lets several components share stateful logic, such as useOnlineStatus() or useDebounce(value). Each component that calls it gets its own state.
73. Do two components using the same custom hook share state?
No. Each call to a custom hook creates separate state. So if two components call useCounter(), each gets its own counter. To share the value, lift it up or put it in context or a store.
74. Write a simple useDebounce hook.
function useDebounce(value, ms) {
const [v, setV] = useState(value);
useEffect(() => {
const t = setTimeout(() => setV(value), ms);
return () => clearTimeout(t);
}, [value, ms]);
return v;
}
The cleanup clears the old timer, so only the last value within the delay wins.
75. What does useId do?
useId() returns a unique ID string that stays the same on the server and the client. Use it to link a label to an input with htmlFor and id. Do not use it for list keys. Also, React 19.2 changed the ID format to begin with _r_.
76. What is useTransition?
useTransition() returns [isPending, startTransition]. Updates inside startTransition are marked as non-urgent, so typing and clicks stay fast while a heavy view renders. Meanwhile, isPending lets you show a small loading hint.
77. What is useDeferredValue?
useDeferredValue(value) gives you a copy of a value that can lag behind during heavy renders. For example, a search box updates at once, while the result list renders with the deferred text. It works like debouncing, but React decides the delay.
78. useTransition or useDeferredValue?
Use useTransition when you own the state update and can wrap it. Use useDeferredValue when you only receive the value, for example as a prop from a parent. Both mark work as lower priority.
79. What does useSyncExternalStore do?
It subscribes a component to a store outside React, such as a browser API or a custom store. You pass subscribe and getSnapshot functions, and React keeps the UI consistent during concurrent renders. State libraries like Redux use it inside.
80. What is useImperativeHandle?
useImperativeHandle(ref, () => ({ open, close })) lets a component choose what a parent sees through a ref. So instead of exposing the raw DOM node, you expose a few methods. Use it rarely, because props are usually enough.
81. What is useDebugValue?
useDebugValue(label) adds a label to a custom hook in React DevTools. For example, a useOnlineStatus hook can show its online status in the panel. It does nothing for users.
82. What does the use API do?
use reads the value of a promise or a context during render. With a promise, the component suspends until it resolves, and the nearest Suspense fallback shows. Unlike other hooks, use can be called inside conditions and loops.
83. What is useEffectEvent?
useEffectEvent became stable in React 19.2. It wraps logic that should read the latest props and state without making the effect rerun. For example, a chat effect can reconnect only when the room changes, while the connected toast still reads the current theme.
84. What is useOptimistic?
useOptimistic shows a temporary state while an async action runs. For example, a new comment appears at once in a faded, pending style, and React swaps in the real data when the server answers. If the action fails, the optimistic value goes away.
85. What is useActionState?
useActionState(action, initialState) returns the current state, a wrapped action and a pending flag. You pass the action to a form, and React stores whatever the action returns, such as an error message. It was named useFormState in early canary builds.
86. What is useFormStatus?
useFormStatus() comes from react-dom and tells a component inside a form if that form is submitting. It returns pending, data, method and action. So a shared SubmitButton can disable itself without any props.
87. Can you call hooks inside a condition?
No, with one exception. Regular hooks must run in the same order each render. However, use is allowed inside if blocks and loops, because React does not track it by position.
88. How do you fetch data in an effect safely?
Ignore results from stale requests:
useEffect(() => {
let ignore = false;
fetch(`/api/user/${id}`).then(r => r.json())
.then(d => { if (!ignore) setUser(d); });
return () => { ignore = true; };
}, [id]);
In real apps, a framework loader or a library like TanStack Query handles caching and race issues for you.
89. Why does an effect run in an endless loop?
Usually the effect sets state that is also in its dependency list, or a dependency is a new object or function each render. For example, useEffect(() => setData({...}), [data]) loops forever. Fix it by removing the dependency, moving the object inside the effect, or memoizing it.
90. What is a stale closure in hooks?
A stale closure happens when a function keeps reading a value from an old render. For instance, a setInterval created once with [] keeps seeing the first count. Use an updater function, add the value to the dependencies, or read it through a ref or useEffectEvent.
Rendering and Performance Questions
91. What causes a component to render again?
A component renders again when its state changes, when its parent renders, or when a context it reads changes. Props changing is a result of the parent rendering. So a parent render alone re-renders all children unless they are memoized.
92. Does re-rendering always update the DOM?
No. Rendering means calling your component and building new elements. Then React compares them and touches the DOM only where something changed. So many renders are cheap, and you only need to fix the slow ones.
93. What does React.memo do?
memo(Component) makes React skip rendering the component when its props are the same as last time, using a shallow compare. It helps when a heavy child gets the same props while its parent changes often. You can also pass a custom compare function.
94. Why does memo sometimes not work?
Usually a prop is a new object, array or function on every render. For example, onClick={() => save(id)} creates a new function each time. Wrap such values in useCallback or useMemo, or let the React Compiler handle it.
95. How do you find slow components?
Open the Profiler tab in React DevTools and record an interaction. It shows which components rendered and how long each took. Also, React 19.2 added Performance Tracks to the Chrome DevTools performance panel, with Scheduler and Components tracks.
96. What is code splitting in React?
Code splitting loads parts of the app only when needed. Use lazy with a dynamic import and wrap it in Suspense:
const Settings = lazy(() => import('./Settings'));
<Suspense fallback={<Spinner />}><Settings /></Suspense>
97. What is Suspense?
<Suspense fallback={...}> shows a fallback while a child is waiting, for example for lazy code or data read with use. When the content is ready, React swaps it in. Several nested boundaries let parts of a page load on their own.
98. What is list virtualization?
Virtualization renders only the rows visible on screen, not all of them. So a table with 50,000 rows still renders about 30 DOM rows. Libraries such as react-window and TanStack Virtual do this.
99. What is concurrent rendering?
Concurrent rendering lets React prepare a new UI in the background and pause it when something urgent happens, like typing. It powers transitions, Suspense and useDeferredValue. You get it by mounting the app with createRoot.
100. What is hydration?
Hydration is when React attaches event handlers and state to HTML that the server already rendered. You call hydrateRoot in place of createRoot. If the client output does not match the server HTML, React reports a hydration mismatch.
101. What is a hydration mismatch, and how do you fix it?
A mismatch happens when the first client render differs from the server HTML, for example by printing Date.now() or reading window. Fix it by rendering the same output on both sides, then updating in an effect. For one unavoidable spot, such as a timestamp, add suppressHydrationWarning.
102. What is server-side rendering (SSR)?
With SSR, the server runs your components and sends HTML, so users see content before the JavaScript loads. Then the client hydrates that HTML. As a result, first paint and SEO improve, but the server does more work per request.
103. What is streaming SSR?
Streaming sends the HTML in pieces. The shell goes out first, and each Suspense boundary streams in when its data is ready. In Node, you use renderToPipeableStream, and in web stream runtimes, renderToReadableStream.
104. What is Partial Pre-rendering?
Partial Pre-rendering, added to React DOM in React 19.2, renders the static shell of a page ahead of time so a CDN can serve it. Later, React resumes and fills in the dynamic parts. The prerender API returns a prelude and a postponed value for that later step.
105. What are the React DevTools?
React DevTools is a browser extension for Chrome, Firefox and Edge. Its Components tab shows the tree with props, state and hooks. Its Profiler tab records renders, so you can see which parts are slow.
106. Why avoid creating components inside other components?
If you define function Row() inside Table, React sees a new component type on every render. So it unmounts and remounts Row each time, losing state and focus. Define components at the top level of the file.
107. Why is an index key bad for performance too?
With index keys, inserting at the top shifts every key by one. So React thinks every row changed and updates them all. Stable IDs let React move just the new row into place.
108. What is windowing compared with pagination?
Pagination splits data into pages that the user clicks through. Windowing keeps one long scroll but renders only visible rows. Choose pagination for search results and windowing for feeds and big tables.
109. How do you avoid layout thrashing in React?
Do reads and writes to the DOM in separate steps. For example, measure in useLayoutEffect once, then set state, and let React write. Also avoid reading offsetHeight inside loops that also change styles.
110. How do you speed up a slow input field?
First, keep the input state as local as possible so typing does not render the whole page. Then defer the heavy part with useDeferredValue or startTransition. Finally, memoize the expensive child so it skips renders while the deferred value catches up.
111. What is the cost of context for performance?
Every reader of a context renders when its value changes, even if it uses only one field. So a single context holding user, theme and cart makes the theme toggle re-render the cart. Split contexts, or move fast-changing data to a store with selectors.
112. How do selectors help in state libraries?
A selector picks just the slice a component needs, such as useStore(s => s.cart.count). The component renders again only when that slice changes. Zustand and Redux both work this way.
113. What is tree shaking, and does it matter for React apps?
Tree shaking removes unused exports at build time. It matters because big libraries can add hundreds of kilobytes. Import only what you use, for example a single icon, and check bundle size with your bundler’s analyzer.
114. What does the React Compiler do?
The React Compiler is a build-time tool that adds memoization to components and hooks for you. So you write plain code, and it skips work that did not change. Version 1.0 became stable in October last year, and it works through a Babel plugin, with support in tools such as Vite and Next.js.
115. What code breaks the React Compiler?
Code that breaks the rules of React, such as mutating props or state, reading refs during render, or calling hooks conditionally. In those spots, the compiler skips the component. The ESLint plugin for React hooks reports these problems before you build.
React 19 Features: Actions, Server Components and More
116. What are the biggest changes in React 19?
React 19, released in December 2024, added Actions, useActionState, useOptimistic, useFormStatus and the use API. It also made ref a normal prop, let you render <Context> as a provider, and supports <title> and <meta> tags inside components. Server Components and Server Functions also became stable for frameworks.
117. What is an Action in React 19?
An Action is an async function you run inside a transition, often from a form. React tracks its pending state, errors and optimistic updates for you. For example, <form action={saveName}> calls saveName with the FormData when the user submits.
118. How do forms work with Actions?
Pass a function to the action prop of a <form>. React calls it with the form data and resets uncontrolled fields after it succeeds. Combined with useActionState, you get the result and a pending flag without writing an onSubmit handler.
119. What are React Server Components?
Server Components run only on the server or at build time and send rendered output to the client, not their code. So they can read a database directly and add zero JavaScript to the bundle. You need a framework that supports them, such as Next.js App Router.
120. What is the difference between Server and Client Components?
Server Components cannot use state, effects or browser APIs, but they can be async and fetch data. Client Components run in the browser and can use hooks and events. A file marked with 'use client' at the top, and everything it imports, becomes client code.
121. What does ‘use server’ mean?
'use server' marks a function as a Server Function that the client can call over the network. For example, a form action that writes to a database can live in a server file. It does not mark a component as a Server Component.
122. Can a Server Component render a Client Component?
Yes. A Server Component can import and render a Client Component and pass it props that can be serialized, like strings, numbers and plain objects. However, a Client Component cannot import a Server Component, though it can receive one as children.
123. What security issues have Server Components had?
In December last year, the React team disclosed a critical flaw in React Server Components. A week later it disclosed a denial of service and source code exposure issue. Teams using RSC frameworks had to update React and their framework at once. So in interviews, mention patching as part of running RSC in production.
124. How do refs work as props in React 19?
Function components can now take ref as a normal prop, so forwardRef is no longer needed for new code. For example, function Input({ ref, ...props }) { return <input ref={ref} {...props} /> }. The React team plans to deprecate forwardRef later.
125. What is a ref cleanup function?
In React 19, a callback ref can return a cleanup function. React calls it when the element leaves the DOM. So you can attach a ResizeObserver in the ref callback and disconnect it in the returned function.
126. How does React 19 handle document metadata?
You can render <title>, <meta> and <link> inside any component. React moves them into the document <head> for you. This works on the client, in streaming SSR and in Server Components.
127. What resource APIs did React 19 add?
React DOM added preload, preinit, preconnect and prefetchDNS. They tell the browser to load fonts, scripts or styles early. Also, stylesheets with a precedence prop are ordered and deduplicated by React.
128. What is the Activity component?
<Activity> became stable in React 19.2. It has two modes, visible and hidden. Hidden content keeps its state but unmounts its effects and gets lower priority. So you can keep a tab’s form input or pre-render the next screen.
129. What is cacheSignal?
cacheSignal, added in React 19.2 for Server Components, returns an AbortSignal tied to the cache() lifetime. When the render finishes, aborts or fails, the signal fires. So you can pass it to fetch and stop work nobody will use.
130. What is the ViewTransition component?
<ViewTransition> is stable in React 19.3. It animates elements as they enter, exit, update or move between places, using the browser’s View Transition API. Animations run only for transitions, such as startTransition updates, Suspense reveals and useDeferredValue updates.
131. What is addTransitionType?
addTransitionType adds a label to a transition, such as 'next' or 'previous'. Then a <ViewTransition> can pick a different animation for each label. React also passes the type to the browser, so CSS can target it with :active-view-transition-type().
132. What are Fragment refs?
Since React 19.3, you can pass a ref to a <Fragment> and get a FragmentInstance. It lets you add event listeners, move focus, observe size or visibility, and scroll across all the fragment’s children as a group. Before this, you needed a wrapper div.
133. What does browser() from react-dom do?
browser() from react-dom, new in React 19.3, opts a component out of server rendering. You call use(browser()) inside the component. On the server it suspends, so the nearest fallback goes into the HTML, and on the client it renders normally.
134. What changed for Trusted Types in React 19.3?
React no longer turns values into strings before passing them to DOM sinks like innerHTML. So TrustedHTML and other Trusted Types objects reach the browser as they are, and your Trusted Types policy can check them.
135. What error handling options did React 19 add?
createRoot and hydrateRoot now accept onCaughtError, onUncaughtError and onRecoverableError. Also, errors are no longer thrown twice. Uncaught errors go to window.reportError, and caught ones go to console.error.
136. What is an error boundary?
An error boundary is a class component that catches errors thrown while rendering its children. It uses static getDerivedStateFromError to show a fallback and componentDidCatch to log. Error boundaries do not catch errors in event handlers or async code.
137. Why are error boundaries still classes?
React has no hook that catches render errors yet. So you write one class boundary, or use the react-error-boundary package, and reuse it around routes and widgets. Event handler errors still need try and catch.
138. What APIs did React 19 remove?
React 19 removed ReactDOM.render, hydrate, unmountComponentAtNode, findDOMNode, string refs, legacy context and createFactory. It also dropped propTypes checks and defaultProps for function components. In addition, react-dom/test-utils is gone, and act now comes from react.
139. What happened to Create React App?
The React team sunset Create React App in February last year. For new apps, react.dev points to frameworks such as Next.js and React Router, or to build tools such as Vite, Parcel and Rsbuild. In an interview, saying you start new apps on CRA is a red flag.
140. What is the React Foundation?
The React Foundation is the new home of React, hosted by the Linux Foundation, announced on February 24, 2026. React, React Native and supporting projects such as JSX are no longer owned by Meta, and the foundation now owns them.
Forms, Events and Refs Questions
141. How does event handling differ from plain HTML?
React events use camelCase names like onClick and take a function, not a string. You call e.preventDefault() to stop the default action, since returning false does nothing. React attaches its listeners at the root container.
142. What is a synthetic event?
A synthetic event is React’s wrapper around the browser event. It has the same interface, such as target and stopPropagation, and works the same in all browsers. Since React 17, events are no longer pooled, so you can read them in async code.
143. How do you pass an argument to an event handler?
Use an arrow function: <button onClick={() => remove(item.id)}>. Do not write onClick={remove(item.id)}, because that calls the function during render. Alternatively, read a data- attribute from e.currentTarget.
144. How do you stop event bubbling?
Call e.stopPropagation() in the handler. For example, a delete icon inside a clickable card should stop the click from opening the card. Also, React has capture handlers such as onClickCapture that run before bubbling handlers.
145. How do you build a controlled form input?
const [email, setEmail] = useState('');
<input value={email} onChange={e => setEmail(e.target.value)} />
The state is the single source of truth. So you can validate as the user types or turn the text to lowercase on the fly.
146. How do you read a form without state?
Give inputs a name and read them on submit with FormData:
function onSubmit(e) {
e.preventDefault();
const data = Object.fromEntries(new FormData(e.currentTarget));
}
With React 19 form actions, you get the FormData as the action’s argument directly.
147. Why does a controlled input warn about changing from uncontrolled?
The warning appears when value starts as undefined and later becomes a string. Then React sees the input switch modes. Always give a starting value, such as useState('').
148. How do you handle checkboxes and selects?
For checkboxes, use the checked prop and read e.target.checked. For a <select>, set value on the select tag itself, not selected on an option. A multi-select takes an array as its value.
149. Which form libraries do React teams use?
React Hook Form is common, because it uses uncontrolled inputs and renders less. Formik is older and still found in many codebases. Many teams pair either one with Zod for schema validation.
150. How do you validate a form?
Use HTML attributes like required and type="email" first. Then add schema checks with Zod or a form library, and show errors next to fields with aria-describedby. Finally, always check again on the server, because the client can be bypassed.
151. What is a portal?
createPortal(children, domNode) renders children into a different DOM node, such as document.body. It is used for modals, tooltips and toasts that must escape a parent’s overflow: hidden. Events from a portal still bubble through the React tree, not the DOM tree.
152. When should you use refs instead of state?
Use a ref for values that do not affect what is on screen, such as a timer ID, a previous value or a DOM node. Use state when a change should update the UI. A good test is to ask if the user would see a difference when the value changes.
153. How do you store the previous value of a prop?
The React docs suggest storing it in state and comparing during render:
const [prev, setPrev] = useState(count);
if (count !== prev) { setPrev(count); setTrend(count > prev ? 'up' : 'down'); }
This avoids an extra effect and an extra paint.
154. How do you handle keyboard access in custom widgets?
Use real elements first, such as <button> and <input>, since they get focus and Enter and Space for free. For custom menus, add the right role, tabIndex and arrow handlers for the keyboard, and follow the ARIA Authoring Practices patterns. Then test with only a keyboard.
155. How do you manage focus after a route change or modal open?
Move focus to the new content’s heading or the first field with a ref in an effect. When a modal closes, return focus to the button that opened it. The native <dialog> element with showModal() handles a lot of this for you.
Routing, Data Fetching and State Management Questions
156. How does client-side routing work?
A router reads the URL and decides which components to render, without a full page reload. It uses the History API to change the address bar. React Router and TanStack Router are common choices, and Next.js has its own file-based router.
157. What are route parameters?
Route parameters are dynamic parts of a path, such as /users/:id. In React Router, read them with useParams(). So /users/42 gives you { id: '42' }, always as a string.
158. How do you protect a route?
Check the user in a layout or loader, and redirect if they are not signed in. In React Router, a loader can throw redirect('/login'). However, client checks only hide screens, so the API must also check access on every request.
159. What is a loader in modern routers?
A loader is a function that fetches data for a route before it renders. React Router and TanStack Router both support them. As a result, data and code load in parallel, and you avoid the waterfall of fetching inside effects.
160. Where should you fetch data in React?
In a framework, fetch in Server Components or route loaders. In a plain client app, use a data library such as TanStack Query or SWR. Fetching in useEffect works but needs extra code for caching, retries and race issues.
161. What does TanStack Query give you?
TanStack Query caches server data and refetches it when it goes stale. It also tracks loading and errors, retries, pagination and mutations that update the cache. So server data stops living in your global store.
162. What is the difference between server state and client state?
Server state is data you fetched, such as orders, which can go stale and is shared with other users. Client state is local UI data, such as an open sidebar. Mixing both in one Redux store is a common source of bugs, so many teams split them.
163. When do you need Redux?
Use Redux when many distant parts of the app read and change the same client data, and you want strict, traceable updates. Redux Toolkit is the standard way to write it now. For a small app, context plus useReducer or Zustand is often enough.
164. What is Redux Toolkit?
Redux Toolkit (RTK) is the official toolset for Redux. createSlice builds reducers and actions together, and Immer lets you write mutating code safely. RTK Query adds data fetching and caching.
165. How does Zustand differ from Redux?
Zustand is a small store library where you create a hook with state and functions in one call. There are no providers, actions or reducers by default. Components subscribe with selectors, so they render only when their slice changes.
166. What are atoms in Jotai or Recoil?
An atom is a small, independent piece of state that components can read and write. Derived atoms compute from other atoms. Recoil is no longer actively maintained, so new projects that want atoms tend to choose Jotai.
167. How do you cancel a fetch when a component unmounts?
Create an AbortController in the effect and pass its signal to fetch. In the cleanup, call controller.abort(). Then catch and ignore the AbortError.
168. How do you show loading and error screens well?
Show a skeleton or spinner where the data will appear, not a full-page block. On error, show a message with a retry button. With Suspense and error boundaries, you can set these per section of the page.
169. What is optimistic UI?
Optimistic UI shows the result of an action before the server confirms it. For example, a like count goes up at once. If the request fails, you roll back and show an error, which useOptimistic or TanStack Query mutations handle.
170. What is the waterfall problem?
A waterfall happens when a child starts fetching only after its parent has finished loading. Each level adds a full round trip. Fix it by fetching in parallel in a loader or by starting requests higher up and passing the results down.
171. How do you share state between tabs or windows?
Use the storage event on localStorage or a BroadcastChannel. Then subscribe with useSyncExternalStore so React reads it safely. Some stores, like Zustand, offer middleware for this.
172. How do you persist state across page reloads?
Save it to localStorage or sessionStorage in an effect or store middleware, and read it in a lazy useState initializer. Keep sensitive data out of browser storage. For anything important, save it on the server.
173. What is the URL as state?
Filters, tabs and page numbers often belong in the URL query string. So users can share or bookmark the exact view. Read and update them with useSearchParams in React Router or a similar hook.
174. What is Next.js, and how does it relate to React?
Next.js is a React framework by Vercel. It adds file-based routing, server rendering, Server Components, Server Functions and image tools. Since Create React App was sunset, it is one of the frameworks react.dev points new apps to.
175. What is the difference between CSR, SSR and SSG?
Client-side rendering (CSR) sends an empty page and renders in the browser. SSR renders HTML on each request, and static site generation (SSG) renders HTML at build time. Many apps mix all three, page by page.
Testing, Tooling and TypeScript Questions
176. How do you test React components?
Most teams use React Testing Library with Jest or Vitest. You render the component, find elements the way a user would, by role or label, and fire events. Then you check what appears on screen, not internal state.
177. Why does Testing Library discourage testing implementation details?
Tests that check state or class names break whenever you refactor, even if the app still works. Tests that use roles and text keep passing as long as the user sees the same thing. So they give you confidence to change code.
178. What is the difference between getBy, queryBy and findBy?
getBy throws if nothing matches. queryBy returns null, so it works for checking that something is absent. findBy returns a promise and waits, so use it for content that appears after a fetch.
179. What is act()?
act() makes sure all updates, effects and timers from an action have run before you check the result. Testing Library wraps most calls in act for you. In React 19, import it from react, not react-dom/test-utils.
180. How do you mock an API in component tests?
Mock Service Worker (MSW) is a common choice, because it intercepts real fetch calls at the network level. So your component code stays unchanged. For simple cases, you can mock the fetch module with vi.mock or jest.mock.
181. How do you test a custom hook?
Use renderHook from React Testing Library. It renders the hook inside a test component and gives you result.current. Wrap updates in act when you call functions the hook returns.
182. What is end-to-end testing for React apps?
End-to-end tests run the whole app in a real browser. Playwright and Cypress are the common tools. They catch problems that unit tests miss, such as routing, auth and API wiring.
183. What is react-test-renderer’s status?
react-test-renderer is deprecated in React 19 and logs a warning. The React team recommends React Testing Library. Snapshot tests built on it should move to other approaches.
184. How do you type props in TypeScript?
Write a type or interface and use it in the function signature:
type ButtonProps = { label: string; onClick?: () => void };
function Button({ label, onClick }: ButtonProps) { /* ... */ }
Avoid React.FC unless your team prefers it, since plain functions are simpler to type.
185. How do you type children and events?
Use React.ReactNode for children. For events, use types like React.ChangeEvent<HTMLInputElement> or React.MouseEvent<HTMLButtonElement>. Also, ComponentProps<'button'> copies all native button props.
186. How do you type useState with null?
Pass a type argument: useState<User | null>(null). Then TypeScript forces you to check for null before reading fields. Without it, TypeScript infers null as the only type.
187. What is Vite, and why do React teams use it?
Vite is a build tool with a fast dev server based on native ES modules. It starts quickly and updates modules without a full reload. It is one of the build tools react.dev lists for starting a React app without a framework.
188. What does ESLint’s hooks plugin do?
eslint-plugin-react-hooks checks the rules of hooks and missing effect dependencies. Since version 6, its recommended preset uses flat config and includes opt-in React Compiler rules. Teams on old config files use recommended-legacy.
189. What are environment variables in a Vite React app?
Vite exposes variables whose names begin with VITE_ through import.meta.env. For example, import.meta.env.VITE_API_URL. Anything you expose this way ends up in the browser bundle, so never put secrets there.
190. How do you style React components?
Common options are CSS Modules, Tailwind CSS, plain CSS files and CSS-in-JS libraries like styled-components. CSS Modules scope class names to a file. With Server Components, runtime CSS-in-JS needs extra setup, so many teams now pick Tailwind or CSS Modules.
React Coding and Scenario Questions
191. Build a counter with increment, decrement and reset.
function Counter() {
const [n, setN] = useState(0);
return (<>
<p>{n}</p>
<button onClick={() => setN(c => c + 1)}>+</button>
<button onClick={() => setN(c => c - 1)}>-</button>
<button onClick={() => setN(0)}>Reset</button>
</>);
}
Interviewers look for the updater form and clean JSX.
192. Build a todo list with add and delete.
Keep an array of { id, text } in state. On submit, add with setTodos(t => [...t, { id: crypto.randomUUID(), text }]). To delete, filter by ID. Also use the ID as the key, and empty the input after adding.
193. Fetch and show users with loading and error messages.
Use an effect with an ignore flag or an AbortController. Keep status as 'loading' | 'error' | 'done' in state. Then render a spinner, an error with retry, or the list based on that status.
194. Build a search box that filters a list as you type.
Keep the query in state and filter during render with items.filter(i => i.name.toLowerCase().includes(q.toLowerCase())). For a large list, pass the query through useDeferredValue. Do not store the filtered list in state.
195. Build a modal that closes on Escape and outside click.
Render it with a portal. Then add a keydown listener in an effect that closes on Escape, with a cleanup. For outside clicks, close when the click target is the backdrop. Also move focus into the modal on open and back on close.
196. Implement infinite scroll.
Put an empty sentinel div after the list and watch it with IntersectionObserver in an effect. When it becomes visible, load the next page and append it. Stop observing when there are no more pages, and disconnect in the cleanup.
197. A list is slow when a parent timer updates every second. What do you do?
First, move the timer state down into the small component that shows it. Then the list no longer renders every second. If you cannot move it, wrap the list in memo and keep its props stable.
198. A user reports old data after switching profiles quickly. Why?
A slow request for the first profile finished after the second and overwrote it. This is a race condition. Fix it with an ignore flag or AbortController in the effect, or use a data library that tracks each request for you.
199. How would you design a reusable Button component?
Accept native button props with ComponentProps<'button'>, plus variant and size. Default type to "button" so it does not submit forms by accident. Forward the ref as a prop, keep styling in one place, and document each variant with Storybook.
200. How would you move a large app from React 18 to React 19?
First, upgrade to React 18.3, which logs warnings for APIs removed in 19. Then fix those, update type packages, and run the official codemods for things like string refs and act imports. Finally, upgrade both react and react-dom together and test in StrictMode.
Read also: 100 Database Questions for Interview
A Seven-Day Prep Plan for React Interviews
Seven days is enough to refresh the basics if you already use React at work. So spend one or two hours a day, and write code each day instead of only reading.
- Day 1: Go through questions 1 to 50 and build a small list app with add, edit and delete.
- Day 2: Cover hooks (questions 51 to 90) and write three custom hooks from memory.
- Day 3: Profile a slow page with React DevTools and fix it with memo or a transition.
- Day 4: Read the React 19 sections and rebuild one form using an Action and
useActionState. - Day 5: Write tests for that form with React Testing Library and MSW.
- Day 6: Do the ten coding tasks at the end under a 30-minute timer each.
- Day 7: Explain five answers out loud and record yourself, then trim anything that runs past a minute.
Also, prepare one project story in depth. Interviewers often ask what you built, what broke and what you would change. For practice projects, the free courses on free coding websites are a good source of ideas.

Questions Candidates Ask About React Interviews
Do I need to know class components for a React interview?
You need to read them, not write new ones. Many older codebases in banks and large IT firms still have class components. So know this.state, the main lifecycle methods and how to convert a simple class to hooks.
Should I learn Next.js before applying for React jobs?
It helps a lot. Many job posts now ask for Next.js, because it is a common way to ship React with server rendering. If you also need to pick a content system for a React project, see this guide on how to choose a CMS for React.
How long should my answers be?
Aim for 30 to 60 seconds per theory answer. Give the definition, one example and one trade-off. Then stop and let the interviewer ask a follow-up.
What should I do if I do not know an answer?
Say so, then reason out loud from what you do know. For example, you might say you have not used Fragment refs but expect them to act like DOM refs on each child. Interviewers often care more about how you think than the exact API name.
How do I talk about pay after a React interview goes well?
Wait for the recruiter to bring it up, then give a range based on your current pay and market data. If the offer comes by email, a short, polite counter works well. These salary negotiation email templates show the wording.





















































































































