19 role-specific questions
React Native Developer Interview Questions & Answers
React Native interviews combine React knowledge with mobile realities: the new architecture, list and animation performance, navigation, offline data, native modules and shipping to the stores.
Free, no sign-up. 102 questions in this role's practice pool, including behavioural, HR and situational questions.
React Native interview questions
The React Native architecture, performance, navigation, native modules and shipping apps.
1.
How does React Native render native UI? Explain the new architecture.
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Understanding what runs where in an RN app.
Key points a strong answer covers
- JS drives native views. JavaScript describes the UI; React Native renders real native views — not a WebView.
- Old bridge. The old architecture sent serialised messages over an async bridge.
- JSI / new architecture. The new architecture uses JSI for direct calls, Fabric for rendering and TurboModules.
- Hermes. Hermes is the default JS engine, optimised for startup.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Saying React Native runs in a WebView.
- Not knowing what JSI changes.
Likely follow-up questions
- What does Fabric improve over the old renderer?
- Why does Hermes improve startup time?
Example strong answer
React Native runs your JavaScript — on the Hermes engine by default — and React describes the UI as a tree of components, but they're rendered as real native views,
UIViews on iOS andViews on Android, not HTML in a WebView. In the old architecture, JavaScript and native code talked over an asynchronous bridge by serialising JSON messages, which added latency and made some interactions janky. The new architecture replaces that with JSI, a C++ interface that lets JavaScript hold references to native objects and call them directly, even synchronously. Fabric is the new renderer built on it, and TurboModules load native modules lazily with type-safe Codegen bindings. Hermes precompiles JS to bytecode, which speeds startup.2.
How do you diagnose and fix performance problems in a React Native app?
AdvancedTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Practical mobile performance work.
Key points a strong answer covers
- Measure. Measure with the performance monitor, React DevTools profiler and native profilers.
- Lists. Use FlatList/FlashList properly for long lists.
- Re-renders. Avoid unnecessary re-renders.
- UI thread animations. Run animations on the UI thread (Reanimated / native driver).
- Images & startup. Optimise images, lazy-load screens, reduce startup work.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Rendering long lists with ScrollView and map.
- Animating with JS-driven state updates.
Likely follow-up questions
- Why do animations stutter when the JS thread is busy?
- What does getItemLayout give FlatList?
Example strong answer
First I measure: the in-app performance monitor shows whether the JS thread or the UI thread is dropping frames, React DevTools' profiler shows which components re-render, and Xcode Instruments or Android Studio profilers cover native work. Common fixes: long lists use FlatList — or FlashList — with stable keys, memoised row components and
getItemLayoutfor fixed heights, never a ScrollView with.map. Animations run on the UI thread with Reanimated oruseNativeDriver, so they stay smooth even when JavaScript is busy. I cut unnecessary re-renders with memoisation and better state placement, resize and cache images, and speed up startup by deferring work and lazy-loading screens.4.
When would you write a native module, and how?
AdvancedTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Ability to go beyond JavaScript when needed.
Key points a strong answer covers
- When needed. When a platform API or SDK isn't available through an existing library, or for heavy native work.
- Check libraries first. Check existing libraries and Expo modules first.
- How. Write Swift/Kotlin code exposed as a TurboModule or with the Expo Modules API.
- Threading / async. Expose async methods returning promises; emit events; mind the threads.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Writing native code for something a maintained library already does.
- Blocking the main thread in native code.
Likely follow-up questions
- How do native modules send events back to JavaScript?
- How would you share the module across iOS and Android?
Example strong answer
Only when JavaScript can't do it: a platform API or vendor SDK with no maintained library — say a payment terminal SDK — or performance-critical work like image processing. First I check for an existing library or Expo module. If I write one, the Expo Modules API is the quickest route: Swift on iOS and Kotlin on Android with a shared, typed JavaScript interface. Without Expo, I'd write a TurboModule with a TypeScript spec that Codegen turns into native bindings. Methods are asynchronous and return promises, events are emitted back to JavaScript for things like progress, and heavy work stays off the main thread.
5.
How would you store data and support offline use in a React Native app?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Mobile data architecture.
Key points a strong answer covers
- Storage options. AsyncStorage/MMKV for small values, SQLite/WatermelonDB for structured data, Keychain/SecureStore for secrets.
- Secrets securely. Tokens go in the Keychain/Keystore, not plain storage.
- Offline queue / sync. Queue changes offline and sync, handling conflicts.
- Cache server data. Cache server data (e.g. persisted TanStack Query).
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Storing auth tokens in AsyncStorage.
- No conflict strategy when syncing.
Likely follow-up questions
- How would you resolve a conflict when the same record changed on two devices?
- How do you detect connectivity changes?
Example strong answer
It depends on the data. Small preferences go in MMKV or AsyncStorage; tokens and secrets go in the iOS Keychain or Android Keystore via a secure storage library, never plain storage. Structured data the user works with offline goes in SQLite, or WatermelonDB for larger datasets. For server data I use TanStack Query with persistence, so screens show cached data instantly. For edits made offline I write locally first, show them optimistically, and queue the changes; when NetInfo reports connectivity, a sync process sends them with retries. Conflicts need a rule — last-write-wins with timestamps for simple fields, or server-side merging and asking the user for important records.
6.
How do you build, release and update a React Native app?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Real shipping experience: builds, signing, store review, updates and rollbacks.
Key points a strong answer covers
- Build pipeline. Automated builds with EAS Build or Fastlane in CI.
- Signing & stores. Code signing, TestFlight/internal testing, store review.
- OTA updates. Over-the-air updates for JS-only changes, within store rules.
- Staged rollout & monitoring. Phased rollouts and crash monitoring.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Shipping native changes via OTA updates.
- No crash reporting.
Likely follow-up questions
- What can't you change with an OTA update?
- How would you roll back a bad release?
Example strong answer
Builds are automated in CI — EAS Build for Expo projects or Fastlane otherwise — with signing credentials stored securely, never on a laptop. Each release goes to TestFlight and Google Play's internal testing track for QA, then through store review with a phased rollout so a bad build reaches a small percentage first. Crash and error monitoring with Sentry or Crashlytics, tagged by app version, tells me whether to continue the rollout. For JavaScript-only fixes, over-the-air updates through EAS Update deliver a new bundle without a store release — within the stores' rules — but anything touching native code or permissions needs a full build. Versioning ties OTA updates to compatible native builds.
React interview questions
Rendering, reconciliation, hooks, state management and performance — from the questions every React interview asks to senior-level depth.
1.
Explain the React rendering process. What happens when state changes?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Whether you understand render vs commit, which underpins performance work.
Key points a strong answer covers
- Triggers. A render is triggered by a state update, a parent re-render or a context change.
- Render phase. React calls your components to get new elements — this should be pure, with no side effects.
- Reconciliation / diff. It compares the new tree with the previous one to work out what changed.
- Commit phase. In the commit phase React applies the minimal DOM changes, then runs effects.
- Batching. Multiple state updates in one event are batched into one render.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Saying a re-render always updates the DOM.
- Putting side effects in the render body.
Likely follow-up questions
- Why must components be pure during render?
- When do
useLayoutEffectanduseEffectrun relative to paint?
Example strong answer
When state changes, React schedules a render of that component — and by default its children. In the render phase React calls the component functions to produce a new tree of elements; that work must be pure, because React may call it more than once or throw it away. It then reconciles: compares the new tree with the previous one to find what actually changed. In the commit phase it applies only those changes to the DOM, runs layout effects, lets the browser paint, and then runs
useEffects. Updates inside one event are batched into a single render. So a re-render doesn't necessarily touch the DOM — it only does if the output differs.2.
How does React reconciliation work, and why do list keys matter?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Understanding of the diffing heuristics and the bugs that bad keys cause.
Key points a strong answer covers
- Heuristic diff. React uses heuristics to diff in O(n) rather than a full tree comparison.
- Type changes remount. If an element's type changes, React throws away that subtree and mounts a new one.
- Keys identify items. Keys tell React which list item is which between renders.
- Index key bugs. Index keys attach state to the wrong item when the list is reordered or items are inserted.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Using
Math.random()as a key. - Thinking keys are only about silencing the console warning.
Likely follow-up questions
- How can you use a key to reset a component's state on purpose?
- What happens if two siblings share a key?
Example strong answer
Reconciliation is how React decides what changed between two renders. A full tree diff would be too slow, so React assumes two things: elements of a different type produce different trees — so if a
<div>becomes a<section>, or one component becomes another, the old subtree is unmounted and a new one mounted — and keys identify children in a list. With stable keys from your data, React can match items even when they move, keeping their state and DOM. With index keys, inserting at the top shifts every key, so state like a text input's value ends up on the wrong row. You can also change a key deliberately to reset a component, like<Profile key={userId} />.3.
What is the difference between useMemo and useCallback? When are they worth using?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Whether you optimise deliberately rather than by habit.
Key points a strong answer covers
- useMemo caches a value.
useMemocaches the result of a calculation between renders. - useCallback caches a function.
useCallbackcaches a function's identity —useCallback(fn, deps)isuseMemo(() => fn, deps). - Dependencies. Both recompute only when their dependencies change.
- When worth it. Worth it for expensive work, props to memoised children, or effect dependencies — measure first.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Wrapping everything in useMemo/useCallback “for performance”.
- Thinking useMemo prevents a component from re-rendering.
Likely follow-up questions
- Why does useCallback do nothing if the child isn't wrapped in React.memo?
- How does the React Compiler change this advice?
Example strong answer
useMemocaches a computed value;useCallbackcaches a function so its identity stays the same between renders —useCallback(fn, deps)is equivalent touseMemo(() => fn, deps). Both recompute only when a dependency changes. They're worth it in three cases: an expensive calculation like filtering thousands of rows, passing an object or callback to a child wrapped inReact.memoso it can skip renders, and keeping a value stable when it's an effect dependency. Otherwise they add complexity for nothing — I measure with the Profiler first. With the React Compiler, much of this memoisation is automatic.- useMemo caches a value.
4.
What are controlled and uncontrolled components?
BeginnerTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Form handling fundamentals.
Key points a strong answer covers
- Controlled = React state. A controlled input's value comes from React state and changes through onChange.
- Uncontrolled = DOM keeps value. An uncontrolled input keeps its own value in the DOM; you read it with a ref or FormData.
- Trade-offs. Controlled suits instant validation and formatting; uncontrolled is simpler and cheaper for big forms.
- Libraries / file inputs. Libraries like React Hook Form are largely uncontrolled; file inputs are always uncontrolled.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Switching an input from uncontrolled to controlled (value undefined → string).
- Not knowing file inputs can't be controlled.
Likely follow-up questions
- What causes the “changing an uncontrolled input to be controlled” warning?
- How would you handle a 50-field form efficiently?
Example strong answer
A controlled input gets its value from React state and updates through
onChange, so React is the single source of truth — ideal when you need instant validation, formatting like a phone mask, or to enable a button as the user types. An uncontrolled input keeps its own value in the DOM; you set adefaultValueand read it on submit with a ref orFormData. That's simpler and avoids a re-render per keystroke, which helps on big forms — React Hook Form is built on this. File inputs are always uncontrolled. A common bug is starting withvalue={undefined}and later passing a string, which flips an input from uncontrolled to controlled.5.
How does useEffect work, and what are the most common mistakes with it?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Correct mental model of effects as synchronisation, not lifecycle methods.
Key points a strong answer covers
- Runs after commit. Effects run after React commits the render to the screen.
- Dependencies. They re-run when dependencies change; missing deps cause stale values.
- Cleanup. The returned cleanup runs before the next effect and on unmount.
- Don't need an effect. Derived state and event-driven logic don't belong in effects; data fetching is better in a library or framework.
- Strict mode double run. In development Strict Mode, effects mount, clean up and mount again to surface missing cleanup.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Using an effect to copy props into state.
- Fetching without cancelling, causing race conditions.
Likely follow-up questions
- Why does my effect run twice in development?
- How do you avoid a race condition when fetching in an effect?
Example strong answer
useEffectsynchronises a component with something outside React — a subscription, a timer, the document title. It runs after the render is committed, and again whenever a dependency changes; the function you return is the cleanup, which runs before the next run and on unmount. The common mistakes are missing dependencies, which give stale values; no cleanup, which leaks listeners; fetching without ignoring stale responses, which causes race conditions; and using effects for things that aren't effects — derived values should be calculated during render, and logic caused by a click belongs in the event handler. In development Strict Mode effects run, clean up and run again to expose missing cleanups.6.
How do you manage complex application state in React?
AdvancedTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Architecture judgement: choosing the simplest tool that fits.
Key points a strong answer covers
- Local first. Keep state as close as possible to where it's used; lift only when needed.
- Server state is different. Remote data belongs in a cache library (TanStack Query, SWR) or the framework, not global state.
- Context for low-frequency. Context suits rarely changing values; frequent updates re-render every consumer.
- Global stores. For complex shared client state: useReducer, Zustand or Redux Toolkit.
- URL state. Filters and selections often belong in the URL.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Putting everything, including API data, in one global store.
- Using Context for fast-changing values like an input.
Likely follow-up questions
- What's the difference between client state and server state?
- When would you pick Redux Toolkit over Zustand?
Example strong answer
I start by sorting state into kinds. Server state — data from APIs — goes in a caching layer such as TanStack Query or the framework's data loading, which handles loading, caching and refetching. URL state, like filters and the current tab, goes in search params so it's shareable. UI state stays local with
useState, lifted only as far as needed, anduseReducerwhen updates have complex rules. Context is for low-frequency values like the theme or current user, since every consumer re-renders on change. Only if there's genuinely complex shared client state — a multi-step editor, say — do I add a store like Zustand or Redux Toolkit.7.
How would you optimise a slow React application?
AdvancedTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
A measured, methodical approach to performance.
Key points a strong answer covers
- Measure first. Profile with the React DevTools Profiler and Performance panel; check Core Web Vitals.
- Reduce re-renders. Avoid unnecessary renders: colocate state, split context, memoise where measured.
- Large lists. Virtualise long lists.
- Bundle / loading. Code-split routes and heavy components; optimise images and bundle size.
- Defer non-urgent work. useTransition / useDeferredValue keep typing responsive; move heavy work to a worker.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Jumping straight to memoising everything without profiling.
- Ignoring network and bundle size and only looking at renders.
Likely follow-up questions
- What does the Profiler's flame graph tell you?
- When would you use
useDeferredValue?
Example strong answer
First I measure, because slow can mean many things. I check Core Web Vitals to see whether it's load time (LCP) or interaction (INP), then profile the slow interaction with the React DevTools Profiler and the browser's Performance panel. For load time: code-split routes and heavy widgets with
lazy, trim the bundle, optimise images. For slow interactions: find components re-rendering unnecessarily — often state too high up or a context with a frequently changing value — and colocate state, split context, or memoise the expensive child. Long lists get virtualised. For heavy filtering while typing,useDeferredValueoruseTransitionkeeps input responsive. Then I measure again to confirm the gain.8.
What are React Server Components, and how are they different from server-side rendering?
AdvancedTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Up-to-date knowledge of modern React architecture.
Key points a strong answer covers
- Render only on the server. Server Components run only on the server; their code never ships to the browser.
- Zero client JS. They add no JavaScript to the bundle.
- Direct data access. They can be async and read databases or secrets directly.
- Client components for interactivity. Interactivity needs Client Components marked with 'use client'.
- Not the same as SSR. SSR renders HTML for the first load then hydrates everything; RSC is about which components ever reach the client.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Saying RSC is just another name for SSR.
- Passing functions or class instances as props from server to client.
Likely follow-up questions
- What can you pass as props from a Server Component to a Client Component?
- Can a Client Component import a Server Component?
Example strong answer
Server Components are components that run only on the server — at build time or per request — and send their rendered result to the client, never their code. So they add no JavaScript to the bundle, can be async, and can read a database or use secrets directly. Anything interactive — state, effects, event handlers — goes in a Client Component marked
'use client', which you can render inside a Server Component, passing serialisable props. That's different from SSR: SSR renders all components to HTML for a fast first paint and then hydrates them all in the browser, so their code still ships. RSC changes which components ever reach the client. In practice you use both together.9.
When do you write a custom hook? Give an example.
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Code organisation and reuse of stateful logic.
Key points a strong answer covers
- Reuse stateful logic. Custom hooks extract and reuse stateful logic between components.
- Naming / rules of hooks. They start with
useand follow the rules of hooks. - Separate state per caller. Each component calling the hook gets its own state; hooks share logic, not state.
- Example. e.g. useDebounce, useLocalStorage, useMediaQuery, useOnlineStatus.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Thinking two components using the same hook share state.
- Wrapping trivial one-liners in hooks.
Likely follow-up questions
- How would you test a custom hook?
- Why must hooks be called in the same order every render?
Example strong answer
I write a custom hook when two or more components need the same stateful logic, or when a component's logic is getting long and has a clear name. For example
useDebouncedValue(value, delay)wraps a state and a timer effect, anduseMediaQuery('(max-width: 640px)')subscribes to a media query and cleans up. A custom hook is just a function starting withusethat calls other hooks, so it follows the rules of hooks — top level, same order every render. Importantly, it shares logic, not state: every component that calls it gets its own independent state. If I need shared state, that's context or a store.10.
What is React Context for, and what are its performance pitfalls?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Knowing when Context is the right tool.
Key points a strong answer covers
- Avoid prop drilling. Context passes data through the tree without prop drilling.
- Good uses. Theme, current user, locale, feature flags — values that change rarely.
- Re-renders all consumers. When the value changes, every consumer re-renders.
- Mitigations. Split contexts, memoise the value object, or use a store with selectors for fast-changing state.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Creating the value object inline so it changes every render.
- Using one giant context for the whole app.
Likely follow-up questions
- Why should the provider's value be memoised?
- How does a store with selectors avoid unnecessary renders?
Example strong answer
Context lets a value reach any depth of the tree without passing props through every level — good for the theme, the signed-in user, the locale or feature flags. The catch is that when the provider's value changes, every component that reads that context re-renders. So I keep fast-changing state out of it, split unrelated values into separate contexts, and memoise the value object —
value={{ user, logout }}inline creates a new object each render and re-renders all consumers. For frequently updated shared state, a store like Zustand with selectors is better because components re-render only when the slice they select changes.11.
How do you handle errors in a React app?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Resilience and user experience when things fail.
Key points a strong answer covers
- Error boundaries. Error boundaries catch render errors in their subtree and show a fallback UI.
- What they don't catch. They don't catch errors in event handlers or async code — handle those with try/catch.
- Placement. Place boundaries around routes and risky widgets, not just the root.
- Reporting & recovery. Report errors to monitoring and offer a retry or reset.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Expecting an error boundary to catch a failed fetch in an event handler.
- One boundary at the root that blanks the whole app.
Likely follow-up questions
- Why are error boundaries class components?
- How would you reset an error boundary after the user retries?
Example strong answer
For rendering errors I use error boundaries: a component — still a class, or a library like react-error-boundary — that catches errors thrown while rendering its children and shows a fallback instead of a blank page. I place them around routes and risky widgets, so a broken chart doesn't take the whole dashboard down, and the fallback offers a retry that resets the boundary. They don't catch errors in event handlers, timers or promises, so those get try/catch and a visible error state. Every caught error is reported to monitoring like Sentry, with enough context to reproduce it.
12.
What do Suspense and transitions (useTransition) do?
AdvancedTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Familiarity with concurrent React features.
Key points a strong answer covers
- Suspense shows a fallback. Suspense shows a fallback while children wait for code or data.
- Works with lazy and data. It works with
lazy()code splitting and Suspense-aware data sources, and enables streaming. - Transitions are non-urgent.
startTransitionmarks an update as non-urgent so urgent input stays responsive. - Avoid jarring loaders. Transitions keep showing the old UI (with
isPending) instead of a fallback flashing.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Thinking Suspense fetches data by itself.
- Wrapping every update in a transition.
Likely follow-up questions
- How does
useDeferredValuediffer fromuseTransition? - How does Suspense enable streaming SSR?
Example strong answer
Suspense lets a component wait for something — code loaded with
lazy(), or data from a Suspense-aware source like a framework loader or theusehook — and shows the nearest boundary's fallback meanwhile. Boundaries let you decide where loading states appear, and on the server they enable streaming HTML in chunks. Transitions are about priority: wrapping an update instartTransitionmarks it as non-urgent, so typing stays responsive while React prepares the new screen in the background, and an already-visible UI isn't replaced by a fallback — you getisPendingto show a subtle indicator. A typical use is switching tabs or filtering a big list.13.
How do you test React components?
IntermediateTechnicalPractise this question and get feedbackWhat the interviewer is evaluating
Testing philosophy and practical tooling.
Key points a strong answer covers
- Test behaviour not implementation. Test what the user sees and does, not internal state.
- Testing Library. React Testing Library queries by role and text.
- User events / async. Simulate real interactions with user-event and await async UI.
- Mock the network. Mock APIs at the network level (MSW) rather than mocking internals.
- Test pyramid. Mostly integration-style component tests, plus a few end-to-end tests with Playwright.
Suggested answer structure
- Define it in one sentence.
- Explain how it works underneath.
- Give a practical example from code or a project.
- Close with a trade-off, pitfall or when you'd use it.
Common mistakes
- Testing internal state or snapshot-testing everything.
- Querying by class names or test ids when a role would do.
Likely follow-up questions
- Why prefer
getByRoleovergetByTestId? - What would you cover with Playwright rather than unit tests?
Example strong answer
I test behaviour the way a user experiences it. With React Testing Library I render the component, find elements by role and accessible name —
getByRole('button', { name: /save/i })— interact with user-event, and assert on what appears. For async UI I usefindByqueries. I mock the network with MSW instead of mocking hooks or modules, so components run their real code. I avoid testing internal state and large snapshots, which break on harmless refactors. Most coverage comes from these integration-style tests, with a handful of Playwright end-to-end tests for critical flows like sign-up and checkout.
Ready to answer them out loud?
Run a timed react native developer mock interview, type or speak your answers, and get a score breakdown with what to improve.