PrepStack › Frontend › React

React interview cheat sheet

Rendering, hooks, state, performance, patterns and React 18/19

React interviews check whether you understand how React decides what to render and when: state snapshots, re-render triggers, reconciliation and keys, and the rules of hooks. Then they move to effects, memoization, state management, React 18 concurrency and the React 19 Actions APIs. JSX examples are illustrative; the plain-JS snippets simulate the logic (batching, stale closures, reducers) and are verified. Read the 15-minute revision, then use Quiz mode and answer out loud.

15-minute revision

  1. A component is a pure function of props + state + context that returns JSX. Rendering must have no side effects; side effects go in event handlers or effects.
  2. A component re-renders when its state changes, its parent re-renders, or a context it reads changes. Props changing alone is not a trigger; the parent re-rendering is.
  3. State is a snapshot per render. setX schedules a new render; it does not change x in the current one. Use setX(prev => ...) when the next value depends on the previous.
  4. React 18+ batches automatically everywhere (events, timeouts, promises). Many setState calls in one tick cause one render.
  5. Reconciliation: different element type at the same position = destroy and rebuild the subtree; same type = update props and recurse. Children lists are matched by key.
  6. Keys must be stable and unique among siblings. Index keys break state when items are inserted, removed or reordered. Changing a key on purpose resets a component.
  7. Rules of hooks: call them only at the top level of components or custom hooks, never in loops, conditions or after an early return. React tracks hooks by call order. (use() is the one exception that can be conditional.)
  8. useEffect runs after paint; useLayoutEffect runs after DOM mutation but before paint. Return a cleanup function; it runs before the next effect and on unmount.
  9. Strict Mode in development double-invokes component bodies and runs effects mount → cleanup → mount to expose impure code and missing cleanups.
  10. useRef holds a mutable .current that survives renders and does not trigger a render when changed. Use it for DOM nodes, timers and previous values.
  11. useMemo caches a value, useCallback caches a function, React.memo skips re-rendering a component when props are shallowly equal. They are optimisations, not guarantees. React Compiler (v1.0, Oct 2025) can add them automatically.
  12. Context is for passing values deeply, not a full state manager: every consumer re-renders when the value changes. Redux/Zustand add selectors, devtools and middleware.
  13. React 18: createRoot, concurrent rendering, useTransition (mark updates non-urgent), useDeferredValue (lag a value), streaming SSR with Suspense.
  14. React 19: Actions (async functions in transitions), useActionState, useOptimistic, useFormStatus, use(), ref as a normal prop, <Context> as provider, Server Components and Server Functions.
  15. Error boundaries are still class components (getDerivedStateFromError + componentDidCatch); they do not catch errors in event handlers or async code.
  16. RTL philosophy: test what the user sees. Prefer getByRole, use findBy* for async UI, queryBy* to assert absence, and user-event for interactions.

Core concepts

Virtual DOM, declarative UI & JSX

You describe what the UI should look like for a given state; React works out the minimal DOM changes.

  • React is a library for building UIs from components. It is declarative: you write UI = f(state) and React keeps the DOM in sync.
  • The virtual DOM is a tree of plain JS objects (React elements) describing the UI. On each update React builds a new tree, compares it to the old one and applies only the differences to the real DOM.
  • The virtual DOM is not “faster than the DOM”. Its value is that you can re-render declaratively and React batches and minimises the real DOM work for you.
  • JSX is syntax sugar. A compiler (Babel, SWC, esbuild, TypeScript) turns <div className="a">hi</div> into jsx('div', { className: 'a', children: 'hi' }) with the automatic runtime (React 17+), so you no longer need import React.
  • JSX rules: one root element (or a <>Fragment</>), close every tag, className and htmlFor, camelCase attributes, and {} for any JS expression (not statements).
  • JSX escapes embedded strings by default, which protects against XSS. dangerouslySetInnerHTML turns that off.

Interview questions

  • What is the virtual DOM and why does React use it?
  • Is the virtual DOM faster than direct DOM manipulation?
  • What does JSX compile to?

Components, props, state & lifting state

Props flow down and are read-only; state is private memory. Shared state lives in the closest common parent.

  • Function components are the standard. Class components still work but are legacy, except for error boundaries.
  • Props are inputs from the parent. They are read-only: never mutate them. children is a prop too.
  • State is data a component owns and changes over time. Updating it with the setter schedules a re-render of that component and its children.
  • One-way data flow: data goes down via props, events go up via callback props (onChange, onSelect).
  • Do not store what you can derive during render (full name from first + last, filtered list from list + query). Duplicated state drifts out of sync.
  • Component names must start with a capital letter; lowercase tags are treated as HTML elements.
  • Lifting state up: when two siblings need the same data, move the state to their nearest common parent and pass it down with setter callbacks.
  • Keep state as low as possible but as high as necessary. Too high causes needless re-renders; too low causes duplication.
  • Lists: items.map(item => <Row key={item.id} {...} />). Filter/sort before mapping, ideally derived during render.
  • Conditionals: cond && <X/>, cond ? <A/> : <B/>, early return null, or a lookup object for many cases.
  • && with a number is a trap: {count && <Badge/>} renders 0. Use count > 0 &&.
  • Fragments group siblings without an extra DOM node; use <Fragment key={id}> when a list item renders several elements.

Interview questions

  • Difference between props and state?
  • Function vs class components?
  • What is derived state and why avoid storing it?
  • What does “lifting state up” mean?
  • Why does {items.length && <List/>} sometimes show 0?

Rendering & re-render triggers

Trigger → render (call components) → commit (touch the DOM). A parent render re-renders all its children by default.

  • Trigger: the initial root.render(), or a state update (setState, dispatch, context change, useSyncExternalStore change).
  • Render phase: React calls your component functions to get new JSX and diffs it. This must be pure and can be paused, repeated or thrown away in concurrent mode.
  • Commit phase: React applies DOM changes, sets refs, then runs layout effects synchronously and passive effects (useEffect) after paint.
  • When a component renders, all its descendants render too, regardless of props, unless they are memoised (React.memo) and their props are equal.
  • If you set state to a value that is Object.is-equal to the current one, React bails out and skips the children.
  • Rendering is not the same as updating the DOM. A render whose output did not change commits nothing.

Interview questions

  • When does a React component re-render?
  • Why does mutating state not update the UI?
  • How do you stop a child re-rendering when its parent re-renders?

Reconciliation & keys

React diffs trees in O(n) using two rules: element type and key. Keys tell React which child is which.

  • A full tree diff is O(n³). React uses a heuristic O(n) algorithm based on two assumptions.
  • Rule 1: elements of different types produce different trees. <div> → <span> or <A> → <B> unmounts the old subtree (state lost) and mounts a new one.
  • Rule 2: for the same type, React keeps the DOM node / component instance and only updates changed props, then recurses into children.
  • For lists, React matches children by key. Without keys (or with index keys) it matches by position.
  • State is tied to a position in the tree, not to the component function. Same component at the same position keeps its state.
  • Giving a component a new key forces a remount, a clean way to reset a form when the selected user changes: <Profile key={userId} />.

Interview questions

  • What is reconciliation?
  • Why are keys needed, and why is the index a bad key?
  • What happens if you change a component's key?

Fiber architecture

Fiber is React's internal reimplementation (React 16) that splits rendering into small units of work that can be paused, prioritised and resumed.

  • Before Fiber, the stack reconciler rendered recursively and synchronously; a big update blocked the main thread until done.
  • A fiber is a JS object for one component or host node: type, key, props, stateNode, the hooks linked list (memoizedState), effect flags, and child/sibling/return pointers.
  • The linked-list shape lets React walk the tree with a loop instead of recursion, so it can stop after any unit of work and yield to the browser.
  • Double buffering: there is a current tree (on screen) and a workInProgress tree being built. On commit React swaps them.
  • Lanes are bit flags for priority: a click (sync/discrete) beats a transition, which beats offscreen work. Higher-priority updates can interrupt lower ones.
  • Fiber is what makes concurrent features possible: Suspense, transitions, useDeferredValue, streaming SSR and selective hydration.

Interview questions

  • What is React Fiber?
  • What are the current and work-in-progress trees?

Hooks

Rules of hooks & custom hooks

Hooks are matched by call order, so call them unconditionally at the top level; package reusable hook logic in use-prefixed custom hooks.

  • Rule 1: call hooks only at the top level: not inside conditions, loops, nested functions, try/catch, or after an early return.
  • Rule 2: call hooks only from React function components or custom hooks (names starting with use), not from regular functions or classes.
  • Why: React stores hook data in a list on the fiber. On each render the Nth hook call reads the Nth slot. Skipping a call shifts every slot after it.
  • eslint-plugin-react-hooks enforces the rules and exhaustive-deps checks dependency arrays. Treat its warnings as bugs.
  • use() (React 19) is the exception: it can be called inside conditions and loops, but still only inside a component or hook.
  • A custom hook is a normal function whose name starts with use and which calls other hooks.
  • It shares logic, not state. Two components calling useOnlineStatus() each get their own state.
  • Good candidates: subscriptions (useWindowSize), data fetching (useFetch), form logic, useDebounce, useLocalStorage, usePrevious.
  • Return whatever shape fits: a value, a tuple [value, setValue], or an object.
  • They replaced HOCs and render props for most logic reuse, because they don't add wrapper components or naming collisions.

Interview questions

  • What are the rules of hooks?
  • Why can't hooks be called conditionally?
  • What is a custom hook and why use one?
  • Do two components using the same custom hook share state?

useState: snapshots, batching & functional updates

setX queues an update for the next render; use the updater form when the new value depends on the old.

  • const [value, setValue] = useState(initial). The initial value is used only on the first render.
  • Lazy initialiser: useState(() => expensive()) runs the function only once. useState(expensive()) calls it on every render and throws the result away.
  • State is a snapshot: inside one render, count is a constant. Calling setCount(count + 1) three times adds 1, not 3.
  • Updater function: setCount(c => c + 1) receives the latest queued value, so three calls add 3.
  • Batching: React groups all updates from one event (and in React 18+, from timeouts, promises and native handlers too) into one render. flushSync forces an immediate render if you really need it.
  • Objects and arrays must be replaced, not mutated: setUser({ ...user, name }), setList(l => l.filter(...)).

Interview questions

  • Why does console.log(count) after setCount(count + 1) print the old value?
  • When should you use the functional updater form?
  • What is automatic batching in React 18?
  • How do you update one field in a nested state object?

useEffect: dependencies, cleanup & Strict Mode

Effects synchronise a component with an external system after render; dependencies decide when they re-run.

  • useEffect(setup, deps) runs after the commit and usually after paint. Use it for subscriptions, network requests, timers, and non-React widgets.
  • Dependencies: no array = after every render; [] = after mount only; [a, b] = when a or b changes (compared with Object.is).
  • Cleanup: the function returned from setup runs before the effect re-runs with new deps and on unmount. Unsubscribe, clear timers, abort fetches.
  • Every reactive value used inside (props, state, functions defined in the component) must be in the deps. Do not silence the lint rule; restructure instead.
  • Strict Mode (dev only) runs an extra setup → cleanup → setup cycle on mount to prove your cleanup works. If the second run breaks things, the effect is missing cleanup.
  • You often don't need an effect: derive values during render, handle user actions in event handlers, reset state with a key, and fetch with a framework or a library (TanStack Query) where possible.

Interview questions

  • Why does my effect run twice in development?
  • How do you avoid race conditions when fetching in an effect?
  • What is a stale closure in hooks?
  • Name cases where you don't need useEffect.

useLayoutEffect & useRef

useLayoutEffect runs before paint for measuring DOM; useRef is a mutable box that persists across renders without re-rendering.

  • useLayoutEffect fires synchronously after DOM mutations, before the browser paints. Use it to measure layout (size, position) and adjust before the user sees a flicker, e.g. tooltip positioning.
  • It blocks painting, so prefer useEffect unless you see a visual glitch. It does nothing during server rendering.
  • useRef(initial) returns { current }. The same object is returned every render. Changing .current does not trigger a render.
  • Uses: DOM access (<input ref={inputRef} />), storing timer ids, previous values, the latest callback, or instance-like variables.
  • Do not read or write ref.current during render (except lazy init); it makes render impure. Do it in effects or handlers.
  • Ref callbacks: ref={node => {...}} runs when the node attaches. In React 19 a ref callback can return a cleanup function.

Interview questions

  • Difference between useEffect and useLayoutEffect?
  • Difference between useRef and useState?
  • How do you get the previous value of a prop?

useMemo, useCallback & React.memo

Cache values, functions and component output between renders to skip work, but only when it measurably helps.

  • useMemo(() => compute(a, b), [a, b]) caches a value until a dep changes.
  • useCallback(fn, [deps]) caches a function reference. It equals useMemo(() => fn, deps).
  • React.memo(Component) skips re-rendering when every prop is shallowly equal (Object.is) to last time. An optional second argument is a custom compare.
  • They work together: React.memo is useless if the parent passes a new object or arrow function each render; useCallback/useMemo keep those references stable.
  • Memoisation costs memory and comparisons. Use it for expensive calculations, props to memoised children, and values used as effect dependencies.
  • React Compiler (stable v1.0, October 2025) memoises components and values automatically at build time, making most manual useMemo/useCallback unnecessary in new code.

Interview questions

  • Difference between useMemo and useCallback?
  • Difference between React.memo and useMemo?
  • Why doesn't my React.memo component skip renders?
  • What is React Compiler?

useContext & useReducer

Context passes data through the tree without prop drilling; useReducer centralises complex state transitions in a pure function.

  • const Ctx = createContext(default). Provide with <Ctx value={v}> (React 19) or <Ctx.Provider value={v}> (older, still works). Read with useContext(Ctx) or use(Ctx).
  • The default value is used only when there is no provider above.
  • Every component that reads the context re-renders when the provider's value changes (Object.is). Passing value={{ user, setUser }} inline creates a new object every render; memoise it.
  • Split contexts by update frequency (e.g. state context and dispatch context) to reduce re-renders.
  • useReducer(reducer, initialArg, init?) returns [state, dispatch]. The reducer (state, action) => newState must be pure and return new objects.
  • dispatch has a stable identity, so it is safe to pass down or omit from deps. Context + reducer is a common lightweight “store” for medium apps.

Interview questions

  • What is prop drilling and how do you avoid it?
  • When do context consumers re-render?
  • When would you choose useReducer over useState?

Building UIs

Controlled vs uncontrolled inputs & forms

Controlled inputs take their value from state; uncontrolled inputs keep it in the DOM and you read it when needed.

  • Controlled: value={text} + onChange={e => setText(e.target.value)}. React state is the single source of truth. Enables live validation, formatting and conditional UI.
  • Uncontrolled: defaultValue + a ref, or read FormData on submit. Less code and fewer renders.
  • Checkboxes use checked/defaultChecked. File inputs are always uncontrolled.
  • Switching an input from undefined value to a defined one triggers the “uncontrolled to controlled” warning. Initialise with ''.
  • React 19: <form action={fn}> calls fn(formData) on submit, inside a transition, and resets uncontrolled fields after success.
  • Large forms: libraries like React Hook Form (uncontrolled, few renders) plus a schema validator (Zod).

Interview questions

  • Difference between controlled and uncontrolled components?
  • What does the “changing an uncontrolled input to be controlled” warning mean?
  • How do forms work in React 19?

Context vs Redux vs Zustand (state management)

Pick by state type: server cache, URL, local UI or shared client state. Context is transport; Redux/Zustand are stores with selectors.

  • Classify state first: server state (fetched data) → TanStack Query / SWR / RTK Query; URL state → router search params; form state → form library; local UI state → useState.
  • Context has no selectors; any value change re-renders all consumers. Fine for low-frequency values: theme, auth user, locale.
  • Redux Toolkit (the recommended way to write Redux): one store, slices with reducers (Immer inside), useSelector subscribes to a slice, strong devtools (time travel) and middleware. Best for large teams and complex flows.
  • Zustand: a tiny hook-based store, no provider needed, selectors to limit re-renders, minimal boilerplate.
  • Others: Jotai/Recoil-style atoms for fine-grained state; MobX for observable/reactive style.
  • Store libraries connect to React via useSyncExternalStore, which avoids tearing under concurrent rendering.

Interview questions

  • Is Context a replacement for Redux?
  • Redux vs Zustand?
  • How would you structure state for a large dashboard app?

Routing, code splitting & Suspense

React Router maps URLs to components without reloads; lazy() + <Suspense> load route code on demand.

  • const Settings = lazy(() => import('./Settings')) creates a component whose bundle is fetched the first time it renders. The module needs a default export.
  • Wrap it in <Suspense fallback={<Spinner/>}>. The nearest Suspense boundary shows the fallback while the code loads.
  • Split by route first (biggest win), then heavy widgets: charts, editors, modals.
  • Suspense also works for data with Suspense-enabled sources: use(promise), framework loaders, TanStack Query's suspense mode. It does not detect fetching inside useEffect.
  • Declare lazy at module level, never inside a component, or the state resets every render.
  • Updates inside a transition don't replace already visible content with a fallback; React keeps the old UI until the new one is ready.
  • React Router v7 ships as the single react-router package (it merged with Remix). It can be used as a library (declarative / data mode) or as a framework (Vite plugin, file routes, SSR).
  • Declarative mode: <BrowserRouter>, <Routes>, <Route path element>, <Link>, <NavLink>, <Outlet> for nested layouts.
  • Hooks: useParams (/users/:id), useNavigate (programmatic navigation), useLocation, useSearchParams (query string state).
  • Data mode: createBrowserRouter + RouterProvider, with loaders (fetch before render) and actions (handle form submissions) per route.
  • Protect routes with a wrapper that checks auth and renders <Navigate to="/login" replace />.
  • Combine with lazy() for route-based code splitting.

Interview questions

  • What is code splitting and how do you do it in React?
  • How does Suspense work?
  • How does client-side routing work?
  • How do you implement a protected route?

Advanced rendering

Error boundaries & portals

Error boundaries catch render errors in a subtree and show a fallback; portals render children into another DOM node while keeping React context and events.

  • An error boundary is a class component with static getDerivedStateFromError (render fallback) and/or componentDidCatch(error, info) (log).
  • It catches errors thrown while rendering, in lifecycle methods and in constructors of children. It does not catch errors in event handlers, async code (setTimeout, promises), SSR, or in itself.
  • Without a boundary, an uncaught render error unmounts the whole root. In React 19, createRoot accepts onCaughtError, onUncaughtError and onRecoverableError for reporting.
  • The community react-error-boundary package gives a function-friendly <ErrorBoundary> with reset support.
  • createPortal(children, domNode) renders children into a different DOM node (modals, tooltips, toasts) to escape overflow: hidden and z-index stacking.
  • Portal content stays in the React tree: it gets context, and events bubble through React ancestors, not DOM ancestors.

Interview questions

  • What is an error boundary and what can't it catch?
  • Why are error boundaries still class components?
  • What is a portal and how do events behave?

React 18: concurrent rendering, transitions & deferred values

Concurrent rendering lets React prepare updates in the background and interrupt them for urgent input; transitions mark which updates can wait.

  • createRoot(el).render(<App/>) enables React 18+ features. Legacy ReactDOM.render was removed in React 19.
  • Concurrent rendering means rendering is interruptible. React can work on a low-priority update, pause for a keystroke, then continue or discard the work.
  • const [isPending, startTransition] = useTransition(). Updates inside startTransition are non-urgent: typing stays responsive and already-shown content is not replaced by Suspense fallbacks.
  • useDeferredValue(value) returns a value that lags behind during urgent updates. Use it when you don't own the setter (e.g. a prop) to render an expensive list with the old value first.
  • Also new in 18: automatic batching everywhere, useId (stable ids for SSR/a11y), useSyncExternalStore, useInsertionEffect (CSS-in-JS), and streaming SSR with selective hydration.
  • Transitions are not debouncing: no fixed delay; React renders as soon as it can and abandons stale renders.

Interview questions

  • What is concurrent rendering?
  • Difference between useTransition and useDeferredValue?
  • How is startTransition different from debouncing?

React 19: Actions, use(), Server Components & Compiler

React 19 adds Actions for async mutations, useActionState/useOptimistic/use(), ref as a prop, and stable Server Components; React Compiler auto-memoises.

  • Actions: async functions passed to startTransition or to <form action>. React tracks pending state, handles errors with boundaries, and supports optimistic updates.
  • useActionState(action, initialState) → [state, dispatchAction, isPending]. The action receives (previousState, payload) and its return value becomes the new state (great for form results and errors).
  • useOptimistic(value, reducer?) → [optimisticState, setOptimistic]: show the expected result immediately while an Action runs; it falls back to the real value when the Action finishes.
  • useFormStatus() (from react-dom) gives { pending, data, method, action } of the parent <form> without prop drilling.
  • use(resource) reads a promise (suspends until resolved) or a context. Unlike hooks, it may be called conditionally.
  • Quality of life: ref is a regular prop for function components (forwardRef no longer needed), <Context value> as provider, ref callback cleanups, <title>/<meta>/<link> hoisted to <head>, stylesheet and script support, better hydration error diffs.
  • Later minors: 19.2 added <Activity> (hide UI but keep state), useEffectEvent and Performance Tracks; 19.3 made <ViewTransition> and Fragment refs stable.
  • React Server Components (RSC) render ahead of time on the server (at build or per request). Their code and dependencies are never shipped to the browser.
  • They can be async and read data directly (DB, file system) without an API layer. They cannot use state, effects, refs, browser APIs or event handlers.
  • 'use client' marks a module boundary: that file and everything it imports become client code. Server Components can render Client Components and pass serialisable props (including JSX as children).
  • Server Functions ('use server') are async functions that run on the server but can be called from the client, typically as form actions. Treat them as public endpoints: validate input and check auth.
  • RSC is stable in React 19 but needs a framework/bundler integration (Next.js App Router, React Router framework mode, Waku, Parcel).
  • React Compiler is separate from RSC: a build-time tool that auto-memoises client and server code. Version 1.0 is stable and is enabled by default in some framework templates.

Interview questions

  • What are Actions in React 19?
  • Explain useActionState.
  • How does useOptimistic work?
  • How is use() different from other hooks?
  • Difference between Server Components and SSR?

Performance, patterns & testing

Performance & profiling

Measure first with the Profiler, then fix the cause: too many renders, expensive renders, or too much JS.

  • React DevTools Profiler records commits and shows which components rendered, how long, and why (enable “Record why each component rendered”). The “Highlight updates” option flashes re-renders.
  • The <Profiler id onRender> component measures render timing in code. React 19.2 adds Performance Tracks in Chrome DevTools' Performance panel.
  • Fix structure first: move state down, lift content up as children, split big contexts, avoid creating components inside components.
  • Then memoise: React.memo, useMemo, useCallback, or enable React Compiler.
  • Long lists: virtualise (react-window, TanStack Virtual) to render only visible rows.
  • Load less: code splitting, lazy images, smaller dependencies, Server Components; keep input responsive with useTransition/useDeferredValue. Track Core Web Vitals (LCP, INP, CLS).

Interview questions

  • How do you find and fix performance issues in a React app?
  • Why does passing children avoid re-renders?
  • Scenario: a dashboard with 50 widgets re-renders on every WebSocket message. What do you do?

Patterns: HOC, render props & compound components

HOCs and render props were the pre-hooks reuse patterns; compound components share implicit state among related parts.

  • Higher-order component (HOC): a function that takes a component and returns an enhanced one (withAuth(Page), Redux connect). Downsides: wrapper hell, prop name collisions, hidden props.
  • Render props: a component takes a function prop (often children) and calls it with data: <Mouse>{pos => <Cursor {...pos}/>}</Mouse>. Flexible but nests deeply.
  • Custom hooks replace both for most logic reuse today. HOCs remain useful for cross-cutting wrappers (auth gates, error boundaries, analytics).
  • Compound components: a parent shares state with children through context: <Tabs><Tabs.List/><Tabs.Panel/></Tabs>. Flexible markup with an implicit API (Radix UI, Headless UI, Reach).
  • Other patterns: container/presentational (less common since hooks), controlled/uncontrolled component APIs (value vs defaultValue), slots via props, provider pattern.

Interview questions

  • HOC vs render props vs custom hooks?
  • What are compound components?
  • How would you design a reusable, accessible Dropdown component?

Testing with React Testing Library

Test behaviour the user sees, query by role and text, and interact with user-event, not implementation details.

  • Guiding principle: *the more your tests resemble the way your software is used, the more confidence they give you*. Avoid testing state or internal methods.
  • Query priority: getByRole (with name) → getByLabelText → getByPlaceholderText → getByText → getByDisplayValue → alt/title → getByTestId as a last resort.
  • Variants: getBy* throws if missing (assert presence), queryBy* returns null (assert absence), findBy* returns a promise that waits (async UI). *AllBy* for multiple.
  • Use @testing-library/user-event (const user = userEvent.setup(); await user.click(btn)) over fireEvent; it simulates full browser interaction sequences.
  • Matchers from @testing-library/jest-dom: toBeInTheDocument, toHaveTextContent, toBeDisabled, toHaveValue.
  • Mock network at the boundary with MSW instead of mocking fetch or hooks. Runners: Jest or Vitest; Playwright/Cypress for E2E.
  • Enzyme is not maintained for modern React; react-test-renderer is deprecated in React 19.

Interview questions

  • What is React Testing Library's philosophy?
  • Difference between getBy, queryBy and findBy?
  • Why prefer user-event over fireEvent?
  • How do you test a component that fetches data?