Offer Ends Jan 10th : Get 100 Free Credits on Signup Claim Now

Interview Questions
December 11, 2025
14 min read

20 React Interview Questions That Go Beyond Memorization

20 React Interview Questions That Go Beyond Memorization

Stop memorizing answers. This guide breaks down the top 20 React.js interview questions and reveals what hiring managers are actually looking for in your response.

Supercharge Your Career with CoPrep AI

The interviewer leaned back, smiled, and asked, “So, can you explain the virtual DOM?”

I froze. I knew the textbook definition, but I couldn't articulate why it mattered or how it worked under the hood. I mumbled something about performance, and the conversation moved on. I didn't get the job. That moment taught me a critical lesson: React interviews aren't about reciting definitions. They're about demonstrating a deep, practical understanding of the concepts that drive the library.

This isn't just another list of questions and answers. This is a strategist's guide. For each question, we'll cover the crisp, correct answer, but more importantly, we’ll explore what the interviewer is really trying to uncover about your skills and thought process.

Foundational Concepts: The Bedrock of React

These are the non-negotiables. If you're shaky here, it's a major red flag. They're testing if you understand the core philosophy of React.

1. What is JSX?

The Short Answer: JSX stands for JavaScript XML. It's a syntax extension for JavaScript that allows you to write HTML-like code inside your JavaScript files. It's not valid JavaScript on its own; it needs to be transpiled by a tool like Babel into React.createElement() calls.

What They're Really Asking: "Do you understand that React components are just functions that return UI descriptions?" They want to see that you know JSX is syntactic sugar, a developer convenience that makes writing React components intuitive. Mentioning React.createElement() shows you've looked under the hood.

2. What's the difference between a Class Component and a Functional Component?

The Short Answer: Historically, Class Components were the only way to have state and lifecycle methods. Functional Components were simpler, stateless "dumb" components. With the introduction of Hooks, Functional Components can now manage state, handle side effects, and do everything Class Components can, but with a more concise and functional syntax.

What They're Really Asking: "Are you up-to-date with modern React practices?" Your answer should heavily favor Functional Components with Hooks. Acknowledge the history of Class Components but frame them as legacy. This shows you're current.

FeatureClass ComponentsFunctional Components (with Hooks)
Statethis.state, this.setState()useState() Hook
Side EffectscomponentDidMount, componentDidUpdateuseEffect() Hook
ContextContext.Consumer or static contextTypeuseContext() Hook
SyntaxMore boilerplate (class, constructor, render)Concise, plain JavaScript functions
this keywordCan be a source of bugs and confusionNot used, simpler scope

3. Explain state vs. props.

The Short Answer: Props (properties) are passed into a component from its parent, making the component configurable. They are immutable within the component. State is managed within a component and represents data that can change over time, triggering a re-render.

What They're Really Asking: "Do you grasp the core concept of data flow in React?" This is fundamental. Emphasize that data flows down (from parent to child via props) and that state is what makes a component dynamic and interactive. A great analogy is that props are like arguments passed to a function, while state is like variables declared inside that function.

Pro Tip: Mention that trying to modify props directly is an anti-pattern and will throw an error in modern React. This demonstrates a respect for React's one-way data flow principle.

4. What is the Virtual DOM and how does it work?

The Short Answer: The Virtual DOM (VDOM) is a programming concept where a virtual representation of a UI is kept in memory and synced with the "real" DOM. When a component's state changes, React creates a new VDOM tree. It then compares this new tree with the previous one (a process called "diffing") and calculates the most efficient way to make these changes in the actual browser DOM.

What They're Really Asking: "Do you understand React's primary performance optimization?" Don't just define it. Explain why it's fast. Manipulating the real DOM is slow and resource-intensive. React minimizes these direct manipulations by batching updates and only changing what's absolutely necessary. This is the secret sauce to React's performance.

Diving into Hooks

Hooks revolutionized React. Mastery here is non-negotiable for any modern React developer role.

5. What is useState?

The Short Answer: It's a Hook that lets you add React state to functional components. It returns an array with two elements: the current state value and a function to update it.

What They're Really Asking: "Can you manage local component state correctly?" Explain that calling the update function (e.g., setCount(5)) enqueues a re-render of the component with the new state value. Mention that state updates are asynchronous and batched for performance.

6. Explain the purpose of useEffect.

The Short Answer: The useEffect Hook lets you perform side effects in functional components. Examples include fetching data, setting up a subscription, or manually changing the DOM. It runs after every render by default.

What They're Really Asking: "Do you know how to handle logic that isn't directly related to rendering?" This is a huge one. Your explanation must include the dependency array.

  • No dependency array useEffect(() => {}): Runs after every single render.
  • Empty dependency array useEffect(() => {}, []): Runs only once, after the initial render (like componentDidMount).
  • With dependencies useEffect(() => {}, [prop, state]): Runs after the initial render and any time a value in the dependency array changes.

Warning: Failing to explain the dependency array is one of the biggest red flags in a React interview. It signals a fundamental misunderstanding of how to control effects, which leads to performance issues and bugs.

7. What is the difference between useMemo and useCallback?

The Short Answer: Both are performance optimization Hooks. useMemo memoizes a value, re-computing it only when its dependencies change. useCallback memoizes a function, returning the same function instance between renders as long as its dependencies don't change.

What They're Really Asking: "Do you understand how to prevent unnecessary re-renders in child components?" Explain the concept of referential equality. When a component re-renders, it creates new functions. If you pass these new functions as props to a child component wrapped in React.memo, the child will re-render unnecessarily. useCallback prevents this. useMemo is for expensive calculations you don't want to re-run on every render.

8. How do you create a custom Hook?

The Short Answer: A custom Hook is a JavaScript function whose name starts with "use" and that can call other Hooks. It's a way to extract and reuse stateful logic from a component.

What They're Really Asking: "Do you know how to write clean, reusable, and maintainable React code?" This isn't about a specific syntax. It's about architecture. Provide an example, like a useFetch or useWindowSize Hook. Explain that it helps avoid duplicating logic across multiple components and keeps components themselves lean and focused on the UI.

State Management & Data Flow

As applications grow, managing state becomes the central challenge. These questions test your ability to think at an application level.

9. What is prop drilling and how can you avoid it?

The Short Answer: Prop drilling is the process of passing props down through multiple layers of nested components to get to a deeply nested child that needs the data. It can be avoided using state management solutions like the Context API or libraries like Redux or Zustand.

What They're Really Asking: "Do you understand the limitations of local state and when to reach for a more robust solution?" Explain that prop drilling makes components less reusable and refactoring a nightmare. Then, introduce the solutions.

10. Explain the React Context API.

The Short Answer: The Context API provides a way to pass data through the component tree without having to pass props down manually at every level. You create a Context, provide a value to it at a high level, and any component in the tree below can consume that value.

What They're Really Asking: "When would you choose Context over another state management library?" Be nuanced. Context is excellent for low-frequency updates of data that many components need, like theme information or user authentication status. Mention that it's not always a great fit for high-frequency updates (like form state) because any component consuming the context will re-render when the value changes, which can lead to performance issues if not managed carefully.

11. What is Redux and what are its core principles?

The Short Answer: Redux is a predictable state container for JavaScript apps. It's based on three principles:

  1. Single source of truth: The state of your entire application is stored in a single object tree (the store).
  2. State is read-only: The only way to change the state is to dispatch an action, an object describing what happened.
  3. Changes are made with pure functions: To specify how the state tree is transformed by actions, you write pure functions called reducers.

What They're Really Asking: "Can you handle complex, application-wide state?" Even if you use other tools like Zustand or MobX, you should understand the concepts Redux popularized. Talk about the benefits: predictable state changes, easy debugging (time-travel debugging), and a clear separation of concerns.

Performance Optimization

Knowing how to write React is one thing. Knowing how to write performant React is what separates a junior from a senior.

12. What is React.memo?

The Short Answer: React.memo is a Higher-Order Component (HOC) that memoizes a component. It performs a shallow comparison of the component's props. If the props haven't changed since the last render, React will skip re-rendering the component and reuse the last rendered result.

What They're Really Asking: "How do you prevent unnecessary component renders?" Connect this directly to useCallback. React.memo is often used with useCallback to prevent re-renders caused by functions passed as props.

13. What is code splitting in React?

The Short Answer: Code splitting is a technique supported by bundlers like Webpack and Vite that allows you to split your code into various bundles which can then be loaded on demand or in parallel. In React, this is done using React.lazy and Suspense.

What They're Really Asking: "Do you know how to improve the initial load time of a large application?" Explain the user benefit: instead of downloading a massive JavaScript bundle for the entire app on the first visit, the user only downloads what's necessary for the initial page. Other parts of the app are loaded as the user navigates to them. This dramatically improves Time to Interactive (TTI).

14. How would you debug a performance issue in a React app?

The Short Answer: The primary tool is the React Developer Tools Profiler. It allows you to record interactions in your app and visualize the render performance of each component. It helps identify which components are re-rendering unnecessarily and why.

What They're Really Asking: "Do you have a systematic approach to problem-solving?" Don't just name the tool. Describe the process. You'd use the Profiler to identify a slow interaction, look at the flame graph to see which components are taking the most time, and then investigate why they are re-rendering. This might lead you to apply React.memo, useMemo, or useCallback.

Advanced & Architectural Questions

These questions probe your deeper knowledge and experience with patterns and architecture.

15. What are keys in React and why are they important?

The Short Answer: Keys are a special string attribute you need to include when creating lists of elements. They help React identify which items have changed, are added, or are removed. Keys should be stable, predictable, and unique.

What They're Really Asking: "Do you understand how React's diffing algorithm works with lists?" Explain what happens if you don't use keys, or worse, use the array index as a key. If you use the index, reordering or adding an item to the beginning of the list can cause React to re-render every single item, potentially losing state in those components. Using a stable ID (like item.id) allows React to efficiently reorder or update elements without unnecessary re-renders.

16. What is a Higher-Order Component (HOC)?

The Short Answer: A Higher-Order Component is an advanced pattern in React for reusing component logic. A HOC is a function that takes a component and returns a new component, usually wrapping the original with additional props or logic.

What They're Really Asking: "Do you know different ways to share logic between components?" This pattern is less common now that Hooks exist, but it's still important to understand. Compare it to custom Hooks, explaining that Hooks are often a simpler and more direct way to achieve the same goal of logic reuse without the extra layer of component nesting.

17. What are controlled vs. uncontrolled components?

The Short Answer: A controlled component is one where its form data is handled by the React component's state. The input's value is driven by React. An uncontrolled component is one where the form data is handled by the DOM itself. You typically use a ref to get the value from the DOM when you need it.

What They're Really Asking: "How do you handle forms in React?" Explain the trade-offs. Controlled components give you more power and predictability—you can validate on the fly and have a single source of truth in your React state. Uncontrolled components are simpler for basic forms and can be easier to integrate with non-React code.

18. Describe the component lifecycle in a modern functional component.

The Short Answer: In functional components with Hooks, the lifecycle is managed primarily with useEffect. The component mounts, useEffect with an empty dependency array ([]) runs. The component updates (re-renders), and useEffect with dependencies runs if those dependencies have changed. Finally, the component unmounts, and the cleanup function returned from useEffect runs.

What They're Really Asking: "Can you map the old Class Component lifecycle methods to their modern Hook equivalents?"

  • componentDidMount: useEffect(() => {}, [])
  • componentDidUpdate: useEffect(() => {}, [dep1, dep2])
  • componentWillUnmount: The cleanup function returned from useEffect.

19. How does error handling work in React?

The Short Answer: You can use Error Boundaries. An Error Boundary is a class component that defines either static getDerivedStateFromError() or componentDidCatch() (or both). It catches JavaScript errors anywhere in its child component tree, logs those errors, and displays a fallback UI instead of the component tree that crashed.

What They're Really Asking: "Do you write resilient applications?" Mention that Error Boundaries don't catch errors in event handlers (use a standard try...catch for those). Explain where you'd place them—perhaps around major UI sections or routes—to prevent a single component failure from crashing the entire application.

20. If you had to build a large-scale application, what would your React tech stack look like and why?

The Short Answer: There's no single right answer here. It depends on the project requirements.

What They're Really Asking: "Can you make reasoned architectural decisions?" This is your chance to shine. Don't just list technologies. Justify your choices.

  • Framework: Next.js for its file-based routing, SSR/SSG capabilities, and performance optimizations.
  • Styling: Tailwind CSS for rapid development and maintainable utility-first styling, or Styled Components for component-scoped CSS-in-JS.
  • State Management: Zustand for its simplicity and minimal boilerplate for global state, or React Query (TanStack Query) for managing server state, caching, and data fetching.
  • Testing: Jest and React Testing Library for a user-centric approach to testing component behavior.
  • Linting/Formatting: ESLint and Prettier to maintain code quality and consistency across the team.

Your goal in any interview isn't just to prove you know React. It's to prove you can think like an engineer. You need to show you understand the trade-offs, the underlying principles, and the why behind the code you write. Master these concepts, not just the answers, and you won't just pass the interview—you'll prove you're the developer they need to hire.

Tags

React interview questions
React.js
JavaScript interviews
frontend developer
React hooks
state management
React developer

Tip of the Day

Master the STAR Method

Learn how to structure your behavioral interview answers using Situation, Task, Action, Result framework.

Behavioral2 min

Quick Suggestions

Read our blog for the latest insights and tips

Try our AI-powered tools for job hunt

Share your feedback to help us improve

Check back often for new articles and updates

Success Story

N. Mehra
DevOps Engineer

The AI suggestions helped me structure my answers perfectly. I felt confident throughout the entire interview process!