InterviewTreedInterviewTreed

InterviewTreed Question Bank

React & TypeScript Interview Questions and Answers

Prepare for React and TypeScript interviews, covering components, hooks, state management, TypeScript types, performance optimization, frontend architecture, and testing.

Total Questions

100

Beginner

30

Intermediate

40

Advanced

30

Beginner Questions

Foundational concepts, terminology, and core ideas.

Q1React Fundamentals

What is React?

React is a JavaScript library for building user interfaces from reusable components.

Answer

React is a JavaScript library for building user interfaces from reusable components.

Key Points

  • Components describe UI
  • State and props drive rendering
Q2React Fundamentals

What is a React component?

A component is a reusable UI unit, commonly a JavaScript or TypeScript function that returns JSX.

Answer

A component is a reusable UI unit, commonly a JavaScript or TypeScript function that returns JSX.

Key Points

  • Component names start with uppercase letters
  • Components compose other components
Q3React Fundamentals

What is JSX?

JSX is a syntax extension that lets you describe UI with markup-like expressions in JavaScript or TypeScript.

Answer

JSX is a syntax extension that lets you describe UI with markup-like expressions in JavaScript or TypeScript.

Key Points

  • Expressions use curly braces
  • Use className for CSS classes
Q4React Fundamentals

What is the difference between props and state?

Props are inputs from a parent; state is data managed by a component that can change over time.

Answer

Props are inputs from a parent; state is data managed by a component that can change over time.

Key Points

  • Props are read-only to the receiver
  • State updates can trigger rendering
Q5React Fundamentals

What is the virtual DOM?

The virtual DOM is an in-memory representation of UI that React reconciles to determine required updates.

Answer

The virtual DOM is an in-memory representation of UI that React reconciles to determine required updates.

Key Points

  • A render does not always mutate the DOM
  • Profile before optimizing
Q6React Fundamentals

Why are keys important in lists?

Keys help React identify list items across insertions, removals, and reordering.

Answer

Keys help React identify list items across insertions, removals, and reordering.

Key Points

  • Prefer stable unique IDs
  • Avoid indexes for reorderable lists
Q7React Fundamentals

What is conditional rendering?

Conditional rendering uses JavaScript conditions to choose which UI to display.

Answer

Conditional rendering uses JavaScript conditions to choose which UI to display.

Key Points

  • Use ternaries for alternatives
  • Avoid accidentally rendering numeric zero
Q8React Fundamentals

What is an event handler?

An event handler is a function passed to props such as onClick or onChange to respond to user actions.

Answer

An event handler is a function passed to props such as onClick or onChange to respond to user actions.

Key Points

  • Pass a function reference
  • Keep handlers focused
Q9React Forms

What is a controlled component?

A controlled input gets its value from React state and updates that state through an event handler.

Answer

A controlled input gets its value from React state and updates that state through an event handler.

Key Points

  • React state is the source of truth
  • Useful for validation
Q10React Forms

What is an uncontrolled component?

An uncontrolled input stores its current value in the DOM, often accessed through a ref or form submission.

Answer

An uncontrolled input stores its current value in the DOM, often accessed through a ref or form submission.

Key Points

  • defaultValue sets initial value
  • Useful for simple forms
Q11React Hooks

What is useState?

useState adds local state to a function component and returns the current value and a setter.

Answer

useState adds local state to a function component and returns the current value and a setter.

Key Points

  • Call hooks at the top level
  • Use functional updates when based on previous state
Q12React Hooks

What is useEffect?

useEffect synchronizes a component with external systems such as subscriptions, browser APIs, or network connections.

Answer

useEffect synchronizes a component with external systems such as subscriptions, browser APIs, or network connections.

Key Points

  • Specify dependencies correctly
  • Return cleanup when needed
Q13React Fundamentals

What is a Fragment?

A Fragment groups multiple elements without adding an extra DOM wrapper.

Answer

A Fragment groups multiple elements without adding an extra DOM wrapper.

Key Points

  • Use <>...</> for simple fragments
  • Use keyed Fragment when needed in lists
Q14React Fundamentals

Functional components versus class components?

Function components use hooks and are standard for new code; class components use lifecycle methods and remain supported.

Answer

Function components use hooks and are standard for new code; class components use lifecycle methods and remain supported.

Key Points

  • Hooks do not work inside classes
  • Understand lifecycle for legacy code
Q15React State

What is lifting state up?

Lifting state up moves shared state to the closest common parent of components that need it.

Answer

Lifting state up moves shared state to the closest common parent of components that need it.

Key Points

  • Pass state and callbacks through props
  • Keep state local where practical
Q16React Fundamentals

What is one-way data flow?

Data generally flows from parent to child through props; children communicate changes using callbacks supplied by parents.

Answer

Data generally flows from parent to child through props; children communicate changes using callbacks supplied by parents.

Key Points

  • Clarifies ownership
  • Do not mutate props
Q17React with TypeScript

Why use TypeScript with React?

TypeScript adds static type checking to JavaScript and documents component contracts during development.

Answer

TypeScript adds static type checking to JavaScript and documents component contracts during development.

Key Points

  • Use precise types
  • External data still needs runtime validation
Q18React with TypeScript

How do you type component props?

Define a type or interface for the props and use it as the component parameter type.

Answer

Define a type or interface for the props and use it as the component parameter type.

Key Points

  • Use optional props only when appropriate
  • Use unions for finite choices
Q19React with TypeScript

How do you type nullable useState state?

Provide a generic such as useState<User | null>(null) when the initial value does not express the full state type.

Answer

Provide a generic such as useState<User | null>(null) when the initial value does not express the full state type.

Key Points

  • Inference works for simple values
  • Model valid states explicitly
Q20React with TypeScript

How do you type an input change handler?

Use React.ChangeEvent<HTMLInputElement> for a conventional input change handler.

Answer

Use React.ChangeEvent<HTMLInputElement> for a conventional input change handler.

Key Points

  • Textarea and select have corresponding element types
  • Inline handlers can often be inferred
Q21React with TypeScript

What is the children prop?

The children prop represents content nested between a component's opening and closing tags.

Answer

The children prop represents content nested between a component's opening and closing tags.

Key Points

  • React.ReactNode is common
  • Use narrower types for constrained children
Q22React Fundamentals

How do null and undefined behave in JSX?

Both generally render no visible content, but they have different JavaScript meanings and may represent different application states.

Answer

Both generally render no visible content, but they have different JavaScript meanings and may represent different application states.

Key Points

  • Use explicit conditions when absence matters
  • Avoid relying only on truthiness
Q23React Fundamentals

What is a React portal?

A portal renders children into a DOM node outside the parent DOM hierarchy while preserving React context and event propagation.

Answer

A portal renders children into a DOM node outside the parent DOM hierarchy while preserving React context and event propagation.

Key Points

  • Useful for modals
  • Manage focus and accessibility
Q24React Fundamentals

What is a ref?

A ref stores a mutable value across renders without causing a re-render when changed.

Answer

A ref stores a mutable value across renders without causing a re-render when changed.

Key Points

  • Use DOM refs for focus or measurement
  • Use state for values that affect UI
Q25React Architecture

What is prop drilling?

Prop drilling passes data through layers that do not use it so a deeper component can access it.

Answer

Prop drilling passes data through layers that do not use it so a deeper component can access it.

Key Points

  • Context may help for widely shared values
  • Composition can avoid some drilling
Q26React Fundamentals

What is React Strict Mode?

Strict Mode enables development-only checks that help reveal unsafe patterns and side effects.

Answer

Strict Mode enables development-only checks that help reveal unsafe patterns and side effects.

Key Points

  • Some logic may be exercised extra times in development
  • Do not depend on development invocation counts
Q27React with TypeScript

Type versus interface in TypeScript?

Both describe object shapes; interfaces support declaration merging, while type aliases can express unions, intersections, and other type expressio...

Answer

Both describe object shapes; interfaces support declaration merging, while type aliases can express unions, intersections, and other type expressions.

Key Points

  • Both work for props
  • Neither validates runtime data
Q28React Hooks

What is a custom hook?

A custom hook is a function starting with use that composes hooks to share stateful logic between components.

Answer

A custom hook is a function starting with use that composes hooks to share stateful logic between components.

Key Points

  • Call hooks only at top level
  • Custom hooks share logic, not automatically state
Q29React Fundamentals

How does React update the UI?

React schedules rendering after relevant updates, reconciles the new element tree, and commits necessary changes to the host environment.

Answer

React schedules rendering after relevant updates, reconciles the new element tree, and commits necessary changes to the host environment.

Key Points

  • Avoid direct state mutation
  • A render does not imply every DOM node changes
Q30React Fundamentals

Rendering versus committing?

Rendering calculates the next UI; committing applies required changes to the host environment such as the DOM.

Answer

Rendering calculates the next UI; committing applies required changes to the host environment such as the DOM.

Key Points

  • Render should be pure
  • Some renders may be restarted

Intermediate Questions

Implementation details, practical patterns, and common workflows.

Q31React Hooks

What are the rules of hooks?

Call hooks only at the top level of function components or custom hooks, never conditionally or inside loops.

Answer

Call hooks only at the top level of function components or custom hooks, never conditionally or inside loops.

Key Points

  • Hook order must remain stable
  • Use lint rules
Q32React Hooks

How does the useEffect dependency array work?

It tells React which reactive values an effect uses to determine when to re-synchronize.

Answer

It tells React which reactive values an effect uses to determine when to re-synchronize.

Key Points

  • Include reactive values used by the effect
  • Do not suppress warnings casually
Q33React Hooks

Why does an effect need cleanup?

Cleanup releases external resources such as subscriptions, timers, listeners, or in-flight work.

Answer

Cleanup releases external resources such as subscriptions, timers, listeners, or in-flight work.

Key Points

  • Runs before re-synchronization when needed
  • Runs on unmount
Q34React Data

How do you prevent stale network responses from overwriting newer results?

Cancel obsolete requests with AbortController or track request identity so only the latest relevant response updates state.

Answer

Cancel obsolete requests with AbortController or track request identity so only the latest relevant response updates state.

Key Points

  • Handle aborts separately
  • Clean up when query changes
Q35React Hooks

What is useMemo?

useMemo caches a calculated value between renders until dependencies change, potentially avoiding expensive recalculation.

Answer

useMemo caches a calculated value between renders until dependencies change, potentially avoiding expensive recalculation.

Key Points

  • Optimization, not correctness guarantee
  • Dependencies must be accurate
Q36React Hooks

What is useCallback?

useCallback caches a function definition until its dependencies change.

Answer

useCallback caches a function definition until its dependencies change.

Key Points

  • Useful when function identity matters
  • Do not apply everywhere automatically
Q37React Performance

What does React.memo do?

React.memo can skip rendering a component when its props are unchanged according to its comparison behavior.

Answer

React.memo can skip rendering a component when its props are unchanged according to its comparison behavior.

Key Points

  • New object props can defeat shallow comparison
  • State and context can still trigger renders
Q38React Performance

How do you optimize a slow React component?

Profile first, then target expensive calculations, unnecessary renders, large lists, or poorly placed state.

Answer

Profile first, then target expensive calculations, unnecessary renders, large lists, or poorly placed state.

Key Points

  • Measure before and after
  • Check network and browser costs too
Q39React Performance

What is list virtualization?

Virtualization renders only visible rows and a small buffer, reducing DOM nodes for large lists.

Answer

Virtualization renders only visible rows and a small buffer, reducing DOM nodes for large lists.

Key Points

  • Useful for very large collections
  • Preserve accessibility
Q40React State

When should you use Context API?

Context shares values needed by many descendants, such as theme, locale, or current user, without passing props through every layer.

Answer

Context shares values needed by many descendants, such as theme, locale, or current user, without passing props through every layer.

Key Points

  • Split contexts by update pattern
  • Context updates can re-render consumers
Q41React State

When use a state management library?

Use one when shared client state has complex updates, debugging needs, or coordination across many components.

Answer

Use one when shared client state has complex updates, debugging needs, or coordination across many components.

Key Points

  • Consider local state first
  • Distinguish server state from client state
Q42React Hooks

What is useReducer?

useReducer manages state through a reducer that receives current state and an action and returns next state.

Answer

useReducer manages state through a reducer that receives current state and an action and returns next state.

Key Points

  • Reducers should be pure
  • Useful for related transitions
Q43React with TypeScript

How do you type a reducer?

Define the state type and a discriminated union for actions, then type reducer arguments and return value.

Answer

Define the state type and a discriminated union for actions, then type reducer arguments and return value.

Key Points

  • Use exhaustive switches
  • Avoid any
Q44React with TypeScript

How do you type a DOM useRef?

Use a generic such as useRef<HTMLInputElement | null>(null) for a DOM ref initialized to null.

Answer

Use a generic such as useRef<HTMLInputElement | null>(null) for a DOM ref initialized to null.

Key Points

  • Check null before access
  • Attach it to a compatible element
Q45React with TypeScript

How do you type a callback prop?

Declare its function signature, such as onSelect: (id: string) => void.

Answer

Declare its function signature, such as onSelect: (id: string) => void.

Key Points

  • Use precise parameter types
  • Keep callback contracts clear
Q46React with TypeScript

How do you type style and className props?

Use React.CSSProperties for inline styles and string for className, or extend native HTML attribute types when wrapping elements.

Answer

Use React.CSSProperties for inline styles and string for className, or extend native HTML attribute types when wrapping elements.

Key Points

  • Prefer CSS classes for most styling
  • Avoid any
Q47React Forms

How do you validate a React form?

Validate values, show accessible field errors, manage submission states, and validate again on the server.

Answer

Validate values, show accessible field errors, manage submission states, and validate again on the server.

Key Points

  • Client validation is not a security boundary
  • Associate errors with fields
Q48React Forms

onChange versus onSubmit?

onChange responds to input changes; onSubmit handles form submission, including Enter-key submission.

Answer

onChange responds to input changes; onSubmit handles form submission, including Enter-key submission.

Key Points

  • Use semantic form elements
  • Prevent default navigation when needed
Q49React Routing

What is client-side routing?

Client-side routing updates the displayed view based on the URL without a full document reload for every navigation.

Answer

Client-side routing updates the displayed view based on the URL without a full document reload for every navigation.

Key Points

  • Support back and forward
  • Handle direct URL loads
Q50React Data

How do you fetch data in React?

Use fetch or a data library and explicitly handle loading, success, errors, cancellation, and caching.

Answer

Use fetch or a data library and explicitly handle loading, success, errors, cancellation, and caching.

Key Points

  • Do not fetch during ordinary render
  • Use framework data APIs where appropriate
Q51React Data

Server state versus client state?

Server state is remotely owned and needs synchronization and caching; client state is owned locally by the UI or application.

Answer

Server state is remotely owned and needs synchronization and caching; client state is owned locally by the UI or application.

Key Points

  • API records are server state
  • Open modal state is client state
Q52React Testing

What is React Testing Library?

It provides utilities for testing components through user-visible behavior and accessible queries.

Answer

It provides utilities for testing components through user-visible behavior and accessible queries.

Key Points

  • Prefer role and label queries
  • Test interactions and outcomes
Q53React Testing

How do you test asynchronous UI?

Wait for observable UI changes and test loading, success, and error states with controlled promises or network mocks.

Answer

Wait for observable UI changes and test loading, success, and error states with controlled promises or network mocks.

Key Points

  • Use findBy or waitFor appropriately
  • Avoid arbitrary sleeps
Q54React Accessibility

How do you make React components accessible?

Use semantic HTML, labels, keyboard support, visible focus, appropriate ARIA, and accessible error messages.

Answer

Use semantic HTML, labels, keyboard support, visible focus, appropriate ARIA, and accessible error messages.

Key Points

  • Prefer native controls
  • Test keyboard navigation
Q55React Error Handling

What is an error boundary?

An error boundary catches certain errors during descendant rendering and can show fallback UI, but does not catch every async or event-handler erro...

Answer

An error boundary catches certain errors during descendant rendering and can show fallback UI, but does not catch every async or event-handler error.

Key Points

  • Can be implemented with a class or library
  • Provide recovery where possible
Q56React Performance

What is code splitting?

Code splitting divides app code into smaller bundles that can load when needed, often through dynamic imports and lazy loading.

Answer

Code splitting divides app code into smaller bundles that can load when needed, often through dynamic imports and lazy loading.

Key Points

  • Reduces initial JavaScript
  • Provide useful loading fallbacks
Q57React Fundamentals

What is reconciliation?

Reconciliation compares previous and next element descriptions to determine necessary UI updates.

Answer

Reconciliation compares previous and next element descriptions to determine necessary UI updates.

Key Points

  • Type and keys affect identity
  • Use stable keys
Q58React Hooks

Why might an effect run too often?

Dependencies may change every render, for example newly created objects or functions, or dependencies may not match the intended synchronization.

Answer

Dependencies may change every render, for example newly created objects or functions, or dependencies may not match the intended synchronization.

Key Points

  • Move calculations when appropriate
  • Keep real dependencies
Q59React State

Why treat state as immutable?

Immutable updates create new references and make changes easier to reason about, avoiding shared mutation bugs.

Answer

Immutable updates create new references and make changes easier to reason about, avoiding shared mutation bugs.

Key Points

  • Use map, filter, and spread appropriately
  • Update nested data deliberately
Q60React with TypeScript

What is a discriminated union?

It models related shapes with a shared literal property so TypeScript can narrow types safely in branches and reducers.

Answer

It models related shapes with a shared literal property so TypeScript can narrow types safely in branches and reducers.

Key Points

  • Useful for async states
  • Use exhaustive checks
Q61React Hooks

useLayoutEffect versus useEffect?

useLayoutEffect runs after DOM mutations but before repaint, useful for layout measurement without flicker; useEffect is generally preferred for ot...

Answer

useLayoutEffect runs after DOM mutations but before repaint, useful for layout measurement without flicker; useEffect is generally preferred for other synchronization.

Key Points

  • Layout effects can block paint
  • Use sparingly
Q62React Fundamentals

What is hydration?

Hydration attaches React behavior to server-rendered HTML so the existing markup becomes interactive.

Answer

Hydration attaches React behavior to server-rendered HTML so the existing markup becomes interactive.

Key Points

  • Initial output should match
  • Browser-only values can cause mismatches
Q63React Fundamentals

What causes hydration mismatch?

It occurs when server HTML differs from the client's initial expected render.

Answer

It occurs when server HTML differs from the client's initial expected render.

Key Points

  • Avoid random initial output
  • Check dates, locale, browser APIs, and invalid HTML
Q64React Data

What is optimistic UI?

Optimistic UI updates the interface before the server confirms a mutation, then reconciles or rolls back if it fails.

Answer

Optimistic UI updates the interface before the server confirms a mutation, then reconciles or rolls back if it fails.

Key Points

  • Provide error recovery
  • Best for predictable actions
Q65React Performance

What is Suspense?

Suspense displays a fallback while supported child operations, such as lazy code loading or framework-integrated data, are pending.

Answer

Suspense displays a fallback while supported child operations, such as lazy code loading or framework-integrated data, are pending.

Key Points

  • Only supported sources suspend
  • Error boundaries handle errors separately
Q66React Architecture

How do you decide where state should live?

Place state at the lowest common owner that needs it, sharing only when multiple consumers need coordination.

Answer

Place state at the lowest common owner that needs it, sharing only when multiple consumers need coordination.

Key Points

  • Keep transient UI state local
  • Separate server and client state
Q67React with TypeScript

How do you type limited component variants?

Use a string literal union such as 'primary' | 'secondary' | 'danger' so invalid values are caught by TypeScript.

Answer

Use a string literal union such as 'primary' | 'secondary' | 'danger' so invalid values are caught by TypeScript.

Key Points

  • Use exhaustive maps or switches
  • Avoid broad string types
Q68React Architecture

What are compound components?

Related components coordinate through composition or context to provide a flexible declarative API, such as Tabs and TabPanel.

Answer

Related components coordinate through composition or context to provide a flexible declarative API, such as Tabs and TabPanel.

Key Points

  • Define accessibility clearly
  • Avoid hidden coupling
Q69React Architecture

What is the render props pattern?

A component receives a function prop that returns UI, letting consumers control rendering while sharing behavior.

Answer

A component receives a function prop that returns UI, letting consumers control rendering while sharing behavior.

Key Points

  • Hooks often replace this pattern
  • Function identity may matter
Q70React Architecture

What is a higher-order component?

A higher-order component is a function that takes a component and returns an enhanced component.

Answer

A higher-order component is a function that takes a component and returns an enhanced component.

Key Points

  • Common in older code
  • Hooks and composition may be simpler

Advanced Questions

Architecture, optimization, and design trade-offs.

Q71React with TypeScript

How do you type a polymorphic component?

A polymorphic component accepts an element type and combines that element's props with its own while resolving prop conflicts.

Answer

A polymorphic component accepts an element type and combines that element's props with its own while resolving prop conflicts.

Key Points

  • Use generic constraints carefully
  • Ref types add complexity
Q72React with TypeScript

How do you wrap native HTML attributes in a component?

Extend the appropriate React HTML attribute type, add custom props, and pass supported attributes to the underlying element.

Answer

Extend the appropriate React HTML attribute type, add custom props, and pass supported attributes to the underlying element.

Key Points

  • Choose the right element type
  • Avoid conflicting prop names
Q73React Testing

Unit versus integration versus end-to-end tests?

Unit tests check isolated logic, integration tests check collaborating parts, and end-to-end tests exercise user journeys through the running app.

Answer

Unit tests check isolated logic, integration tests check collaborating parts, and end-to-end tests exercise user journeys through the running app.

Key Points

  • Balance test types
  • Test behavior
Q74React Testing

How do you test a component that depends on an API?

Control the network boundary and test loading, success, empty, and failure states through visible behavior.

Answer

Control the network boundary and test loading, success, empty, and failure states through visible behavior.

Key Points

  • Use deterministic fixtures
  • Avoid implementation coupling
Q75React Data

How do query libraries help React apps?

They manage server-state fetching, caching, deduplication, retries, background refresh, and invalidation.

Answer

They manage server-state fetching, caching, deduplication, retries, background refresh, and invalidation.

Key Points

  • Examples include TanStack Query
  • Design cache keys carefully
Q76React Architecture

How should authentication be handled in React?

Use a trusted authentication flow and protect server APIs independently of client UI checks; prefer secure server-side session handling where appro...

Answer

Use a trusted authentication flow and protect server APIs independently of client UI checks; prefer secure server-side session handling where appropriate.

Key Points

  • Client route guards are not authorization
  • Avoid long-lived secrets in browser storage
Q77React Security

How does React help prevent XSS?

React escapes text rendered through normal JSX, but unsafe HTML insertion and other DOM sinks can still create XSS risks.

Answer

React escapes text rendered through normal JSX, but unsafe HTML insertion and other DOM sinks can still create XSS risks.

Key Points

  • Avoid untrusted dangerouslySetInnerHTML
  • Sanitize rich HTML
Q78React Architecture

What is micro-frontend architecture?

Micro-frontends split a frontend into independently developed or deployed parts integrated into a larger experience.

Answer

Micro-frontends split a frontend into independently developed or deployed parts integrated into a larger experience.

Key Points

  • Define contracts and shared dependencies
  • Integration complexity can be high
Q79React Performance

How do you improve initial load performance?

Measure bundle costs, split routes, optimize assets, reduce blocking work, and consider server rendering or static generation when appropriate.

Answer

Measure bundle costs, split routes, optimize assets, reduce blocking work, and consider server rendering or static generation when appropriate.

Key Points

  • Track Core Web Vitals
  • Test on realistic devices
Q80React Architecture

CSR versus SSR versus SSG?

CSR builds much of the UI in the browser; SSR produces HTML per request; SSG produces HTML ahead of requests.

Answer

CSR builds much of the UI in the browser; SSR produces HTML per request; SSG produces HTML ahead of requests.

Key Points

  • Each has different caching and latency trade-offs
  • Hydration makes server HTML interactive
Q81React with TypeScript

How do you model loading, success, and error states safely?

Use a discriminated union such as loading, success with data, and error with an error value so each state contains only valid fields.

Answer

Use a discriminated union such as loading, success with data, and error with an error value so each state contains only valid fields.

Key Points

  • Narrow by status
  • Handle cases exhaustively
Q82React Hooks

Why can an effect create an infinite loop?

An effect may update state that changes one of its dependencies, causing the effect to run repeatedly.

Answer

An effect may update state that changes one of its dependencies, causing the effect to run repeatedly.

Key Points

  • Derive values during render when possible
  • Check dependencies
Q83React State

How do you avoid stale state updates?

Use functional updates such as setCount(previous => previous + 1) when the next value depends on the previous state.

Answer

Use functional updates such as setCount(previous => previous + 1) when the next value depends on the previous state.

Key Points

  • Useful for queued updates
  • Reducers help complex transitions
Q84React Architecture

What is state colocation?

State colocation keeps state near the components that use it, reducing coupling and unnecessary broad updates.

Answer

State colocation keeps state near the components that use it, reducing coupling and unnecessary broad updates.

Key Points

  • Lift only when sharing is needed
  • Clear ownership aids refactoring
Q85React Data

How do you handle search-as-you-type race conditions?

Cancel obsolete requests or track request identities and apply results only for the latest query.

Answer

Cancel obsolete requests or track request identities and apply results only for the latest query.

Key Points

  • Debouncing alone does not guarantee correctness
  • Handle cancellation separately
Q86React Security

How do you safely render user-provided rich text?

Sanitize rich text and render it through a controlled, reviewed path that restricts unsafe tags, attributes, and URL schemes.

Answer

Sanitize rich text and render it through a controlled, reviewed path that restricts unsafe tags, attributes, and URL schemes.

Key Points

  • Do not trust client validation alone
  • Test malicious input
Q87React Architecture

How do you design reusable components without over-generalizing?

Start from real repeated use cases, expose a small typed API, build in accessibility, and add flexibility only when it serves known needs.

Answer

Start from real repeated use cases, expose a small typed API, build in accessibility, and add flexibility only when it serves known needs.

Key Points

  • Prefer composition to many boolean flags
  • Document constraints
Q88React Performance

What are Core Web Vitals?

Core Web Vitals measure user experience including loading, responsiveness, and visual stability, commonly represented by LCP, INP, and CLS.

Answer

Core Web Vitals measure user experience including loading, responsiveness, and visual stability, commonly represented by LCP, INP, and CLS.

Key Points

  • Use real-user measurements where possible
  • React is only one performance factor
Q89React Architecture

What should you consider when upgrading React?

Review migration guidance, dependency compatibility, changed behavior, tooling, tests, and warnings; upgrade incrementally where practical.

Answer

Review migration guidance, dependency compatibility, changed behavior, tooling, tests, and warnings; upgrade incrementally where practical.

Key Points

  • Run type checks and tests
  • Validate production behavior
Q90React with TypeScript

Why validate API responses at runtime if using TypeScript?

TypeScript types disappear at runtime, so external data needs runtime validation when correctness or security depends on its shape.

Answer

TypeScript types disappear at runtime, so external data needs runtime validation when correctness or security depends on its shape.

Key Points

  • Treat network data as unknown until checked
  • Handle invalid responses gracefully
Q91React Architecture

How would you design a large data table?

Separate fetching, table state, columns, and row rendering; use server-side pagination when suitable and virtualization for large lists.

Answer

Separate fetching, table state, columns, and row rendering; use server-side pagination when suitable and virtualization for large lists.

Key Points

  • Avoid thousands of unnecessary DOM rows
  • Test keyboard navigation
Q92React Architecture

How would you build a design system with React and TypeScript?

Create accessible primitives, typed APIs, design tokens, documentation, visual tests, and versioned package releases.

Answer

Create accessible primitives, typed APIs, design tokens, documentation, visual tests, and versioned package releases.

Key Points

  • Start with frequently reused components
  • Automate accessibility checks
Q93React Hooks

What is useTransition?

useTransition marks updates as non-urgent so React can keep urgent interactions responsive during less urgent rendering.

Answer

useTransition marks updates as non-urgent so React can keep urgent interactions responsive during less urgent rendering.

Key Points

  • Does not make CPU work inherently faster
  • Use pending state to inform UX
Q94React Hooks

What is useDeferredValue?

useDeferredValue lets part of the UI lag behind a rapidly changing value so expensive rendering can be deprioritized.

Answer

useDeferredValue lets part of the UI lag behind a rapidly changing value so expensive rendering can be deprioritized.

Key Points

  • Not a fixed-time debounce
  • Useful for expensive filtered views
Q95React Hooks

What is useImperativeHandle?

useImperativeHandle customizes the value exposed through a ref so a component can expose a limited imperative API.

Answer

useImperativeHandle customizes the value exposed through a ref so a component can expose a limited imperative API.

Key Points

  • Use sparingly
  • Expose only necessary methods
Q96React Performance

useMemo versus memo?

useMemo caches a calculated value inside a component; memo can skip rendering a component when its props remain unchanged.

Answer

useMemo caches a calculated value inside a component; memo can skip rendering a component when its props remain unchanged.

Key Points

  • They optimize different things
  • Use profiling to decide
Q97React Architecture

How do you choose between client state and server state libraries?

Use local state for component UI, context for suitable shared values, and query libraries for remote data synchronization and caching.

Answer

Use local state for component UI, context for suitable shared values, and query libraries for remote data synchronization and caching.

Key Points

  • Avoid adding libraries without need
  • Define ownership and invalidation
Q98React Architecture

What is the strangler approach to frontend migration?

Gradually replace parts of a legacy UI by routing selected functionality to new components or applications while the old system continues to work.

Answer

Gradually replace parts of a legacy UI by routing selected functionality to new components or applications while the old system continues to work.

Key Points

  • Migrate incrementally
  • Define boundaries and rollback plans
Q99React Security

How would you investigate a suspected frontend security issue?

Reproduce safely, identify the input and rendering path, assess exposure, remove unsafe sinks, deploy a fix, and add regression tests.

Answer

Reproduce safely, identify the input and rendering path, assess exposure, remove unsafe sinks, deploy a fix, and add regression tests.

Key Points

  • Do not expose sensitive data in logs
  • Review related code paths
Q100React Performance

Why can context cause performance issues?

When a provider value changes, consumers of that context may re-render even if they use only part of the value.

Answer

When a provider value changes, consumers of that context may re-render even if they use only part of the value.

Key Points

  • Split contexts by update pattern
  • Keep provider values stable when useful

Share this question bank

Send this page to someone preparing for an interview.