This page is for frontend developers preparing for React rounds in 2026, from freshers facing their first technical interview to engineers with several years of experience moving into senior or lead roles. Service companies still test fundamentals such as JSX, props, state and hooks rules. Product companies and funded startups go further: they ask why a component re-renders, when an effect is the wrong tool, how Server Components change data fetching, and how you would debug a hydration mismatch or a slow list in production.
The questions are grouped by level: freshers, intermediate, experienced (3+ years) and scenario-based problems drawn from real projects. Each answer explains what a strong response includes and where candidates usually slip. The set was compiled by VidhaiX trainers who run mock interviews for our frontend batches, and it reflects React 19, the React Compiler and the Next.js App Router as they are used today.
How to Prepare for a React Interview
- Build one small app end to end with the Next.js App Router, mixing Server and Client Components, a form that uses an Action, and a Suspense boundary with a loading state.
- Re-read the "You Might Not Need an Effect" page on react.dev and rewrite two effects from your own code as derived state or event handlers.
- Open the React DevTools Profiler on a real screen, record an interaction, and be ready to explain which components re-rendered and why.
- Practise explaining reconciliation and keys with a concrete bug, such as input values jumping between rows when list items are keyed by array index.
- Write React Testing Library tests that query by role and label, plus one Playwright test for the same flow, so you can compare unit and end-to-end coverage.
- Know when you would choose plain state, context, Zustand, Redux Toolkit or TanStack Query, and be able to defend the choice in two sentences.
- Trigger and fix a hydration error deliberately, for example by rendering a date or Math.random() on the server, so the error message is familiar.
React Interview Questions for Freshers
12 questions
Q1.What is JSX, and what does it compile to?
JSX is a syntax extension that lets you describe UI as markup inside JavaScript. A compiler such as SWC, Babel or esbuild turns each element into a function call. With the modern automatic runtime, <Button size="sm" /> becomes roughly jsx(Button, { size: "sm" }) imported from react/jsx-runtime, which is why you no longer need import React in every file.
A strong answer adds that JSX is just expressions: you can use map, ternaries and &&, but not statements like if inside the braces. Watch for {count && <List />} rendering a literal 0.
Q2.What is the difference between props and state?
Props are inputs passed from a parent; the component treats them as read-only. State is data the component owns and changes over time through a setter such as the one returned by useState. Changing either causes a re-render, but only the owner can change state.
Interviewers want you to mention lifting state up: when two siblings need the same data, move the state to their closest common parent and pass it down as props. A weak answer copies props into state, which creates two sources of truth that drift apart.
Q3.What are the rules of hooks, and why do they exist?
Call hooks only at the top level of a component or custom hook, never inside conditions, loops or nested functions, and only from React function components or other hooks. React identifies each hook by its call order on every render, so a hook that runs conditionally shifts every later hook onto the wrong stored value.
Mention that eslint-plugin-react-hooks enforces these rules and that the React Compiler relies on them. The newer use() API is the one documented exception: it can be called conditionally.
Q4.Why do list items need a key, and why is the array index often a bad key?
Keys tell React which item in a list is which between renders, so it can move, insert or remove DOM nodes and preserve each item's state correctly. Without stable keys React falls back to position.
The index breaks when items are reordered, filtered or inserted at the top: state such as an input value or an open accordion stays attached to the position, not the item, so it appears to jump to the wrong row. Use a stable id from the data. Index keys are acceptable only for static lists that never change order.
{todos.map((todo) => (
<TodoRow key={todo.id} todo={todo} />
))}Q5.What triggers a re-render in React?
A component re-renders when its own state changes, when its parent re-renders, or when a context it reads changes. Props changing is not a separate trigger; it happens because the parent re-rendered. A re-render means React calls the function again and diffs the result, not that the DOM is rewritten.
A common trap is believing that passing the same props prevents a re-render. By default it does not; children re-render with their parent unless they are memoized, either by memo or automatically by the React Compiler.
Q6.Why should you not mutate state directly?
React decides whether to re-render by comparing the old and new state with Object.is. If you push into an existing array and call the setter with the same reference, React sees no change and may skip the update. Mutation also breaks memoization and makes bugs hard to trace.
Create new objects instead: spread for shallow updates, map and filter for arrays, or structuredClone or Immer for deeply nested data. Also mention functional updates, setCount(c => c + 1), when the next value depends on the previous one.
// wrong: same reference, may not re-render
items.push(newItem)
setItems(items)
// right
setItems((prev) => [...prev, newItem])Q7.What is the virtual DOM, and is it what makes React fast?
React keeps a tree of elements in memory, and on each render it compares the new tree with the previous one, a process called reconciliation, then applies the minimum set of DOM changes. That tree is often called the virtual DOM.
A good candidate does not claim the virtual DOM is inherently faster than the real DOM. Its value is a declarative model with acceptable performance. Diffing has a cost too, which is why unnecessary re-renders, huge lists and expensive render functions still matter.
Q8.What is the difference between controlled and uncontrolled inputs?
A controlled input gets its value from React state and reports changes through onChange, so React is the single source of truth. An uncontrolled input keeps its own value in the DOM; you read it through a ref or from FormData on submit, and set the initial value with defaultValue.
Controlled inputs suit instant validation and dependent fields. Uncontrolled inputs are simpler and pair naturally with React 19 form Actions. The classic warning appears when a value switches from undefined to a string, changing an input from uncontrolled to controlled.
Q9.What does useEffect do, and when does it run?
useEffect synchronises a component with something outside React, such as a subscription, a timer, a browser API or a third-party widget. It runs after the browser paints, and again whenever a value in its dependency array changes. The function it returns is the cleanup, run before the next effect and on unmount.
Mention that in development Strict Mode mounts, unmounts and remounts components once to expose missing cleanup. Interviewers also like hearing that effects are not for transforming data for rendering or reacting to user events.
Q10.What is useRef used for?
useRef returns a mutable object whose current property persists across renders without causing a re-render when it changes. Two uses: holding a reference to a DOM node, such as focusing an input, and storing instance values like a timer id or the previous value of a prop.
The trap is reading or writing ref.current during render, which makes output unpredictable. In React 19, function components can receive ref as a normal prop, so forwardRef is no longer needed for new code.
function Search() {
const inputRef = useRef<HTMLInputElement>(null)
return (
<>
<input ref={inputRef} />
<button onClick={() => inputRef.current?.focus()}>Focus</button>
</>
)
}Q11.What are fragments, and why would you use them?
A fragment, written <>...</> or <Fragment>, groups several children without adding an extra DOM node. Components must return a single root, and wrapping everything in a div can break layouts, especially CSS grid, flexbox and table markup where a div inside a tr is invalid HTML.
Use the long form <Fragment key={id}> when rendering a list of grouped elements, because the short syntax cannot take a key. It is a small question, but a crisp answer signals you care about clean markup.
Q12.How do you lift state up, and when is that not enough?
When two components need the same data, move the state to their nearest common parent, pass the value down as props and pass a callback for changes. This keeps a single source of truth and is the default answer for sharing state.
It stops being enough when the common parent sits far above, forcing you to pass props through many layers that do not use them. Then consider composition (passing components as children), context for low-frequency values, or a store. For server data, a cache like TanStack Query is usually the better fit.
React Intermediate Interview Questions
12 questions
Q13.Explain "You Might Not Need an Effect". Which effects would you remove?
Effects are an escape hatch for syncing with external systems. Many effects in real code compute derived data or respond to user events, and both belong elsewhere. Derived values like a filtered list or full name should be calculated during render. Logic caused by a click or submit belongs in the event handler. Resetting state when a prop changes is better done with a key.
Removing these effects eliminates extra renders and stale intermediate states. A strong candidate can point to a specific effect they deleted in their own code.
// avoid
const [fullName, setFullName] = useState('')
useEffect(() => setFullName(first + ' ' + last), [first, last])
// prefer: derive during render
const fullName = first + ' ' + lastQ14.What are the common pitfalls with useEffect dependency arrays?
Omitting dependencies causes stale closures: the effect keeps reading values from the render it was created in. Adding an object or function created during render causes the effect to run on every render, sometimes looping if it sets state. Suppressing the lint rule hides both problems.
Fixes include moving the function inside the effect, depending on primitive values instead of objects, using functional state updates, and in React 19.2 or later useEffectEvent for logic that should read the latest values without re-triggering. Always return a cleanup for subscriptions and fetches.
Q15.How would you fetch data in a client component without race conditions?
If you fetch in an effect, the response for an old query can arrive after the newer one and overwrite it. Guard with an ignore flag or an AbortController in the cleanup so stale responses are discarded.
The better answer for most apps is not to hand-roll this. Fetch in a Server Component, or use TanStack Query or SWR on the client, which handle caching, deduplication, retries and cancellation. Interviewers want to see that you know the manual pattern and also know why libraries exist.
useEffect(() => {
const controller = new AbortController()
fetch('/api/search?q=' + query, { signal: controller.signal })
.then((r) => r.json())
.then(setResults)
.catch(() => {})
return () => controller.abort()
}, [query])Q16.When do useMemo and useCallback actually help, and how does the React Compiler change this?
useMemo caches a computed value and useCallback caches a function between renders. They help when a calculation is measurably expensive, or when a stable reference is needed by a memo child or an effect dependency. Wrapping everything adds noise and comparison cost for little benefit.
The React Compiler, stable since late 2025, analyses components at build time and inserts memoization automatically, so new code needs far fewer manual hooks. It only works on components that follow the rules of React, and you still keep manual memoization where the compiler bails out.
Q17.How does React.memo work, and why does it often fail to prevent re-renders?
memo wraps a component so React skips re-rendering it when its props are shallowly equal to the previous props. It is an optimisation, not a guarantee.
It fails silently when the parent passes a new object, array or inline function on every render, because shallow comparison sees a new reference. It also does nothing for context changes or the component's own state. Fix the references with useMemo or useCallback, or let the React Compiler do it. Always confirm with the Profiler that memo actually saved work.
Q18.Why can React Context cause performance problems, and how do you avoid them?
Every component that calls useContext (or use) on a context re-renders whenever the provider value changes. If the value is an object created inline in the provider, it changes on every provider render, so all consumers re-render even when nothing they use changed.
Memoize the provider value, split unrelated data into separate contexts (for example state and dispatch), and keep high-frequency data such as form input or cursor position out of context. When many components need slices of frequently changing state, a selector-based store like Zustand is a better tool.
Q19.What are custom hooks, and what makes a good one?
A custom hook is a function starting with use that calls other hooks to reuse stateful logic, such as useDebouncedValue or useMediaQuery. Each component that calls it gets its own independent state; hooks share logic, not state.
A good hook has a narrow purpose, a clear return shape and handles cleanup. Interviewers watch for hooks that merely wrap an effect for something that should be derived, or hooks named use that call no hooks at all. Test them with renderHook from React Testing Library.
function useDebouncedValue<T>(value: T, delay = 300) {
const [debounced, setDebounced] = useState(value)
useEffect(() => {
const id = setTimeout(() => setDebounced(value), delay)
return () => clearTimeout(id)
}, [value, delay])
return debounced
}Q20.What are error boundaries, and what do they not catch?
An error boundary is a component that catches errors thrown during rendering of its children and shows a fallback instead of unmounting the whole tree. They are still written as class components using getDerivedStateFromError and componentDidCatch, or through the react-error-boundary package. In Next.js, error.tsx creates one per route segment.
They do not catch errors in event handlers, async code outside rendering such as a setTimeout, or errors in the boundary itself. Handle those with try/catch and report them to your monitoring tool.
Q21.How do you choose between Zustand, Redux Toolkit and TanStack Query?
First separate server state from client state. Data owned by the backend, such as lists and user profiles, belongs in TanStack Query or a similar cache, which handles fetching, caching, invalidation and refetching. Many apps that adopted Redux for this find most of their store disappears.
For the remaining client state, local useState covers most needs. Zustand fits small to medium shared state with minimal boilerplate and selectors. Redux Toolkit suits large teams wanting strict conventions, middleware and devtools time travel. A strong answer justifies the choice instead of naming a favourite.
Q22.How do you implement code splitting in React?
Use lazy with a dynamic import() so a component's code loads only when it renders, and wrap it in Suspense with a fallback. Split at route level first, then heavy widgets like charts, editors and maps that most users never open.
In Next.js the App Router splits per route automatically, and next/dynamic handles client-only components. Mention that you verify gains with a bundle analyzer and that too many tiny chunks can create waterfalls; preloading on hover or intent is a useful middle ground.
const ReportChart = lazy(() => import('./ReportChart'))
function Dashboard() {
return (
<Suspense fallback={<ChartSkeleton />}>
<ReportChart />
</Suspense>
)
}Q23.How do you make React components accessible?
Start with semantic HTML: real button, a, label and heading elements give keyboard support and screen reader semantics for free. Associate every input with a label, manage focus when dialogs open and close, provide visible focus styles, and use useId for stable ids linking labels and descriptions.
Use ARIA only to fill gaps, not to fix a clickable div. For complex widgets like comboboxes, a tested headless library such as Radix or React Aria is safer than building your own. Verify with keyboard-only navigation, axe checks and a screen reader.
Q24.How do you test React components with React Testing Library?
Test behaviour the way a user sees it. Render the component, find elements by role, label or text with queries like getByRole, interact with userEvent, and assert on visible output. Avoid testing internal state or implementation details, because those tests break on every refactor.
Use findBy queries for async results, mock the network with MSW rather than mocking fetch per test, and run under Vitest or Jest with jsdom. A strong candidate notes that async Server Components are better covered by end-to-end tests with Playwright.
test('shows error for empty email', async () => {
const user = userEvent.setup()
render(<SignupForm />)
await user.click(screen.getByRole('button', { name: /sign up/i }))
expect(await screen.findByText(/email is required/i)).toBeInTheDocument()
})React Interview Questions for Experienced (3+ Years)
11 questions
Q25.Walk me through how React renders and commits an update.
A state update schedules work with a priority (lane). In the render phase React calls components, builds the new fiber tree and diffs it against the current one. This phase is pure and interruptible in concurrent rendering, so React can pause it for urgent input. In the commit phase it applies DOM mutations synchronously, runs layout effects and ref callbacks, then the browser paints and passive effects (useEffect) run.
Strong answers mention automatic batching of updates, and that reconciliation compares element type and key: a different type at the same position destroys the subtree and its state.
Q26.What are React Server Components, and how do they differ from Client Components?
Server Components run only on the server (at build or request time). They can be async, read databases or files directly, and send no JavaScript to the browser; their output is serialised as the RSC payload. Client Components, marked with "use client" at a module boundary, are pre-rendered to HTML and then hydrated, and can use state, effects and browser APIs.
Key rules: a Server Component can render Client Components and pass serialisable props, including Server Components as children, but a Client Component cannot import a Server Component. Keep the client boundary as low in the tree as possible.
Q27.How do Suspense and streaming work together in a React 19 app?
A Suspense boundary shows its fallback while something inside it is not ready, such as a lazy component, an async Server Component or a promise read with use. With streaming server rendering, the server sends the shell HTML immediately and streams each boundary's content as its data resolves, so a slow query does not block the whole page.
Design boundaries around meaningful UI regions, not every component, to avoid popcorn loading. In the Next.js App Router, loading.tsx wraps a route segment in Suspense automatically.
export default function Page() {
return (
<>
<Header />
<Suspense fallback={<OrdersSkeleton />}>
<RecentOrders />
</Suspense>
</>
)
}Q28.Explain Actions, useActionState and useFormStatus in React 19.
An Action is an async function used in a transition; you can pass it directly to a form's action prop and React handles pending state, error handling and form reset. useActionState(action, initialState) returns the latest result, a wrapped action to give the form and an isPending flag, which is ideal for validation errors from a Server Function.
useFormStatus reads the pending state of the parent form from inside a child component, typically a submit button, without prop drilling. It must be called in a component rendered inside the form.
function SignupForm() {
const [state, formAction, isPending] = useActionState(signup, { error: null })
return (
<form action={formAction}>
<input name="email" type="email" />
{state.error && <p role="alert">{state.error}</p>}
<button disabled={isPending}>Sign up</button>
</form>
)
}Q29.How does useOptimistic work, and what are its risks?
useOptimistic(state, updateFn) returns a temporary value shown while an Action is pending. You call the optimistic setter inside the Action, the UI updates instantly, and when the Action finishes React discards the optimistic value and shows the real state from the server.
Risks: if the request fails, the item disappears, so you need visible error feedback and a retry path. Do not use it for operations where a false success is costly, like payments. Make sure server-generated values such as ids or timestamps are reconciled when the real data arrives.
Q30.What does the use() hook do, and how is it different from other hooks?
use reads the value of a promise or a context during render. With a promise it suspends the component until it resolves, letting the nearest Suspense boundary show a fallback and the nearest error boundary handle rejection. Unlike other hooks, it can be called inside conditions and loops.
The catch: the promise must be stable. Creating it inside a Client Component during render creates a new promise each time and loops. The common pattern is to start the fetch in a Server Component and pass the promise down to a Client Component that calls use.
// server
const commentsPromise = getComments(postId)
return <Comments commentsPromise={commentsPromise} />
// client
function Comments({ commentsPromise }: { commentsPromise: Promise<Comment[]> }) {
const comments = use(commentsPromise)
return comments.map((c) => <p key={c.id}>{c.body}</p>)
}Q31.What causes hydration errors, and how do you fix them properly?
Hydration attaches React to server-rendered HTML and expects the first client render to match it exactly. Mismatches come from values that differ between server and client: Date.now(), Math.random(), locale or timezone formatting, reading window or localStorage during render, invalid nesting like a div inside a p, and browser extensions modifying the DOM.
Fix the cause: render browser-only values after mount, pass a fixed timestamp from the server, or move the widget into a client-only component. suppressHydrationWarning is acceptable only for single, intentional text differences such as a timestamp.
Q32.How do you profile and fix a slow React screen?
Measure first. Record the interaction with the React DevTools Profiler to see which components rendered, how long they took and why. Use the browser Performance panel to separate React work from layout, paint and long tasks, and check field data such as Interaction to Next Paint.
Typical fixes: move state down so fewer components re-render, stabilise props passed to memoized children, virtualise long lists with TanStack Virtual, defer non-urgent updates with useTransition or useDeferredValue, and move heavy work to the server. Re-measure after each change.
Q33.What do useTransition and useDeferredValue solve?
Both mark work as non-urgent so React can keep urgent updates, like typing, responsive. useTransition wraps a state update you control; React renders it in the background, can interrupt it, and gives you isPending. In React 19 the transition function can be async, which is the basis of Actions. useDeferredValue gives you a lagging copy of a value when you do not control the update, such as a prop.
Neither makes slow code faster. They help only if the expensive child is memoized, so the deferred render can be skipped or interrupted.
Q34.How does the Next.js App Router organise a React application?
Routes are folders under app/, with page.tsx for the UI, layout.tsx for shared shells that persist across navigation, loading.tsx for Suspense fallbacks, error.tsx for error boundaries and route.ts for API handlers. Components are Server Components by default.
Data is fetched in async Server Components, mutations go through Server Functions ("use server"), and caching and revalidation are configured explicitly. A strong candidate explains the static versus dynamic rendering trade-off and checks the current Next.js docs, because caching defaults have changed between major versions.
Q35.How would you structure a large React codebase for multiple teams?
Organise by feature or domain rather than by file type, so a team owns features/billing with its components, hooks, tests and API calls together. Keep a shared design system package with accessible primitives and tokens, enforce boundaries with lint rules or a monorepo tool like Nx or Turborepo, and make public APIs of each feature explicit.
Mention conventions that scale: TypeScript strict mode, colocated tests, Storybook for components, a single server-state library, and an architecture decision record when introducing a new pattern. Avoid premature micro-frontends; they solve organisational problems at a real runtime cost.
React Scenario-Based Interview Questions
8 questions
Q36.A search input feels laggy because filtering a 10,000-row table re-renders on every keystroke. What do you do?
First confirm with the Profiler that the table render is the cost. Then keep the input state urgent and let the table lag: pass the query through useDeferredValue and memoize the table so React can interrupt stale renders. Virtualise rows so only visible ones mount.
If filtering itself is expensive, memoize the filtered result or move filtering to the server with a debounced request. A weak answer only adds a debounce, which hides the problem and makes typing feel delayed.
const deferredQuery = useDeferredValue(query)
const rows = useMemo(() => filterRows(allRows, deferredQuery), [allRows, deferredQuery])
return (
<>
<input value={query} onChange={(e) => setQuery(e.target.value)} />
<VirtualTable rows={rows} />
</>
)Q37.Production logs show a hydration mismatch on the product page, but you cannot reproduce it locally. How do you investigate?
Look at what differs between the server and real users: timezone and locale (prices and dates formatted differently), A/B flags or personalisation read from cookies on one side only, user-agent-based rendering, and browser extensions or translation tools altering the DOM. React 19 error messages include a diff, so capture it in your error monitoring.
Reproduce by setting the browser timezone and locale to match a failing user, and test with a production build. Fix by making server and first client render deterministic, then deferring client-only differences until after hydration.
Q38.After adding a theme and user context at the app root, typing in any form became slow. What happened and how do you fix it?
Likely the provider value is an inline object, or form state was placed in the same context, so every keystroke changes the value and re-renders every consumer across the app. The Profiler will show many components re-rendering with "context changed" as the reason.
Keep form state local to the form, memoize provider values, and split contexts so theme, user and frequently changing data are separate. If many components need slices of shared, fast-changing state, move it to a store with selectors such as Zustand.
Q39.A dashboard shows stale data after a user saves a form, until they refresh. How do you fix it?
The save succeeded but the cached read was not invalidated. With TanStack Query, call queryClient.invalidateQueries for the affected keys in the mutation's onSuccess, or update the cache directly with setQueryData. In the Next.js App Router, call revalidatePath or revalidateTag (or the newer cache APIs your version provides) inside the Server Function after the write.
A strong answer also checks for a second copy of the data in local state, an effect that copied props into state once and never synced again.
Q40.Your React Testing Library tests pass, but the checkout flow broke in production. What would you change in your testing strategy?
Component tests with mocked APIs cannot catch broken integrations, routing, Server Components or real browser behaviour. Add a small set of Playwright end-to-end tests for critical journeys such as login and checkout, running against a production build in CI, with traces captured on failure.
Keep RTL for component logic and edge cases, add contract tests or typed API clients so mocks match the real backend, and review whether mocks were hiding the failure. The goal is a balanced pyramid, not replacing one tool with another.
Q41.The initial JavaScript bundle doubled after a release and mobile users complain. How do you track it down?
Run a bundle analyzer on both builds and compare. Common causes: a large library imported in a shared layout, a barrel file pulling in a whole icon or date library, a "use client" directive added high in the tree turning a large subtree into client code, or a heavy dependency that should be lazy loaded.
Fix by moving the client boundary down, importing specific modules, lazy loading rarely used widgets and moving rendering to Server Components. Add a bundle size budget check in CI so this is caught at review time.
Q42.A modal component leaks: after opening and closing it many times, memory grows and old handlers still fire. How do you debug it?
Suspect effects without cleanup: event listeners on window or document, intervals, subscriptions or third-party widgets created on mount and never destroyed. Strict Mode in development helps expose this by mounting effects twice.
Take heap snapshots in Chrome DevTools before and after several open-close cycles and look for detached DOM nodes and retained closures. Fix by returning cleanup functions, aborting pending fetches, and calling the widget's destroy method. Add a test that unmounts the component and asserts no listeners remain.
Q43.You are asked to migrate a Create React App project to a modern stack. How do you plan it?
Create React App is deprecated, so the target is usually Vite for a pure client app or Next.js if you need SEO, server rendering or Server Components. Start by upgrading React and fixing deprecation warnings, then move the build tool with minimal code changes, keeping routes and behaviour identical.
Migrate incrementally: environment variables, absolute imports and test setup (Jest to Vitest) first, then routing or data fetching changes in later steps. Keep end-to-end tests green throughout and ship behind a staged rollout rather than one big switch.