React Interview Questions

Updated 5/11/2026

Top React JS Interview Questions

In the rapidly evolving world of web development, React JS has become one of the most popular JavaScript libraries for building user interfaces. Created by Facebook in 2013, React has revolutionized how developers approach front-end development, offering a component-based architecture that makes building complex, interactive UIs more manageable and efficient.

Whether you're preparing for an interview, starting a new project, or simply exploring this technology, this comprehensive guide will provide you with a solid foundation in React JS and help you ace your technical interviews.

What is React JS?

React JS (commonly referred to as just "React") is an open-source JavaScript library developed and maintained by Facebook (now Meta) for building user interfaces, particularly single-page applications. Unlike full frameworks like Angular, React focuses specifically on the view layer of applications, making it more flexible and easier to integrate with other technologies.

Key Characteristics of React

Component-Based

Build encapsulated components that manage their own state, then compose them to create complex UIs

Declarative

Tell React what you want to achieve, and it handles DOM updates to match that state

Virtual DOM

Lightweight in-memory representation optimizes rendering performance

Unidirectional Data Flow

Data flows one direction from parent to child, making apps more predictable

Why Use React?

  • Performance — Virtual DOM significantly improves rendering compared to direct DOM manipulation
  • Component Reusability — Build once, use everywhere with self-contained components
  • Strong Community — Vast ecosystem with extensive documentation, tutorials, and third-party libraries
  • Industry Adoption — Used by Facebook, Instagram, Netflix, Airbnb, Dropbox, and many more

React Fundamentals

1. What is React?

React is an open-source JavaScript library created by Facebook for building user interfaces, especially single-page applications. It's component-based, declarative, and uses a Virtual DOM for efficient rendering. React focuses solely on the view layer, making it flexible to integrate with other technologies and libraries.

2. What is JSX?

JSX (JavaScript XML) is a syntax extension for JavaScript that looks similar to HTML. It allows you to write HTML-like code in your JavaScript files, making it easier to visualize the UI you're building.

const element = <h1>Hello, world!</h1>;

This JSX gets compiled to regular JavaScript:

const element = React.createElement('h1', null, 'Hello, world!');

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

The Virtual DOM is a lightweight, in-memory representation of the real DOM. React's reconciliation process works as follows:

  • Creates a virtual representation of the UI in memory
  • When state changes, creates a new Virtual DOM and compares it with the previous one (diffing)
  • Calculates the most efficient way to update the browser's DOM
  • Performs only the necessary updates to the real DOM

This minimizes expensive DOM operations, making React applications fast and responsive.

4. What are the key features of React?

  • JSX — HTML-like syntax in JavaScript
  • Components — Reusable, self-contained pieces of UI
  • Virtual DOM — Efficient rendering optimization
  • One-way data binding — Predictable data flow
  • High performance — Optimized reconciliation algorithm
  • SEO friendly — Server-side rendering capability

5. What is the difference between React and Angular?

Aspect React Angular
Type JavaScript library Full-fledged framework
Language JavaScript (JSX) TypeScript
DOM Virtual DOM Real DOM
Data Binding One-way Two-way
Learning Curve Moderate Steep

Components

6. What are the types of React components?

Functional Components — JavaScript functions that accept props and return React elements:

function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}

Class Components — ES6 classes that extend React.Component:

class Welcome extends React.Component {
  render() {
    return <h1>Hello, {this.props.name}</h1>;
  }
}

Since React 16.8 with Hooks, functional components can handle state and lifecycle, making them the preferred approach.

7. What are Pure Components?

Pure Components are components that only re-render when their props or state actually change. They implement a shallow comparison of props and state in shouldComponentUpdate.

class MyComponent extends React.PureComponent {
  render() {
    return <div>{this.props.value}</div>;
  }
}

// Functional equivalent
const MyComponent = React.memo(({ value }) => {
  return <div>{value}</div>;
});

8. What is a higher-order component (HOC)?

A Higher-Order Component is a function that takes a component and returns a new component with additional props or behavior. It's a pattern for reusing component logic.

function withLoading(Component) {
  return function WithLoadingComponent({ isLoading, ...props }) {
    if (isLoading) return <div>Loading...</div>;
    return <Component {...props} />;
  };
}

const EnhancedComponent = withLoading(MyComponent);

Props and State

9. What are Props in React?

Props (short for "properties") are how components receive data from their parent. They are read-only and help make components reusable.

function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}

// Usage
<Welcome name="Sara" />

10. What is the difference between props and state?

Aspect Props State
Ownership Passed from parent Owned by component
Mutability Read-only Can be changed
Updates From parent Via setState or useState
Purpose Configuration Manage changing data

11. What is prop drilling?

Prop drilling is the process of passing props through multiple layers of components to reach a deeply nested component that needs the data. This can make code hard to maintain.

Solutions:

  • Context API for global state
  • State management libraries (Redux, Zustand)
  • Component composition

React Hooks

12. What are React Hooks?

Introduced in React 16.8, Hooks allow you to use state and other React features in functional components without writing a class. They provide a more direct API to React concepts.

Basic Hooks:

  • useState — Adds state to functional components
  • useEffect — Performs side effects
  • useContext — Subscribes to React context

13. What is the useState hook?

useState is a Hook that lets you add state to functional components. It returns an array with the current state value and a function to update it.

import React, { useState } from 'react';

function Counter() {
  const [count, setCount] = useState(0);

  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>
        Click me
      </button>
    </div>
  );
}

14. What is the useEffect hook?

useEffect lets you perform side effects in functional components. It combines the functionality of componentDidMount, componentDidUpdate, and componentWillUnmount.

useEffect(() => {
  // Side effect code here
  document.title = `You clicked ${count} times`;

  // Cleanup function (optional)
  return () => {
    document.title = 'React App';
  };
}, [count]); // Only re-run if count changes

15. What is the difference between useMemo and useCallback?

Aspect useMemo useCallback
Returns Memoized value Memoized function
Purpose Optimize expensive calculations Optimize function references
Use case Avoid recalculating values Prevent unnecessary re-renders

16. What are the rules of hooks?

  • Only call Hooks at the top level — Don't call Hooks inside loops, conditions, or nested functions
  • Only call Hooks from React functions — Call Hooks from React functional components or custom Hooks, not regular JavaScript functions

Lifecycle and Effects

17. What are the lifecycle methods in React?

Class components have lifecycle methods divided into three phases:

Mounting:

  • constructor()
  • componentDidMount()

Updating:

  • shouldComponentUpdate()
  • componentDidUpdate()

Unmounting:

  • componentWillUnmount()

With Hooks, useEffect replaces most lifecycle methods.

18. How do you replicate componentDidMount with useEffect?

useEffect(() => {
  // This runs once after the component mounts
  console.log('Component mounted');
}, []); // Empty dependency array

Event Handling

19. What is a synthetic event in React?

Synthetic events are React's cross-browser wrapper around the browser's native events. They have the same interface as native events but work identically across all browsers.

function handleClick(e) {
  e.preventDefault(); // e is a synthetic event
  console.log('The link was clicked.');
}

20. How is event handling different in React compared to HTML?

  • React events are named using camelCase: onClick not onclick
  • Pass functions as event handlers: onClick={handleClick} not onclick="handleClick()"
  • Cannot return false to prevent default — must call e.preventDefault()

State Management

21. What is Redux?

Redux is a predictable state container for JavaScript applications. It centralizes application state and logic, making state changes predictable and traceable through a unidirectional data flow.

Core concepts:

  • Store — Single source of truth for application state
  • Actions — Plain objects describing what happened
  • Reducers — Pure functions that specify how state changes

22. What is the Context API?

The Context API provides a way to share data that can be considered "global" for a tree of React components, without having to pass props down manually at every level.

const ThemeContext = React.createContext('light');

function App() {
  return (
    <ThemeContext.Provider value="dark">
      <Toolbar />
    </ThemeContext.Provider>
  );
}

function ThemedButton() {
  const theme = useContext(ThemeContext);
  return <button className={theme}>Themed Button</button>;
}

Advanced Concepts

23. What are error boundaries?

Error boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI. They catch errors during rendering, in lifecycle methods, and in constructors.

class ErrorBoundary extends React.Component {
  constructor(props) {
    super(props);
    this.state = { hasError: false };
  }

  static getDerivedStateFromError(error) {
    return { hasError: true };
  }

  componentDidCatch(error, errorInfo) {
    console.log(error, errorInfo);
  }

  render() {
    if (this.state.hasError) {
      return <h1>Something went wrong.</h1>;
    }
    return this.props.children;
  }
}

24. What is code-splitting in React?

Code-splitting is a technique to split your bundle into smaller chunks that can be loaded on demand. React supports code-splitting through dynamic import() and React.lazy.

const OtherComponent = React.lazy(() => import('./OtherComponent'));

function MyComponent() {
  return (
    <Suspense fallback={<div>Loading...</div>}>
      <OtherComponent />
    </Suspense>
  );
}

25. What is React Suspense?

Suspense lets components "wait" for something before rendering. Currently, Suspense only supports lazy loading components with React.lazy, but it will support data fetching and other async operations in the future.


Master React Through Practice! This guide covers essential React interview questions from fundamentals to advanced topics. The key to success is building real projects, understanding the "why" behind each concept, and staying updated with React's evolving ecosystem.

React Ecosystem Tools

  • Create React App — Official tool for setting up new React projects
  • Next.js — Framework for server-rendered React applications
  • React Router — Standard routing library for React
  • Redux Toolkit — Official, opinionated Redux development toolkit
  • React Testing Library — Testing utilities for React components
  • React Native — Framework for building native mobile apps

Additional Resources

Best of luck with your React interviews! Remember that understanding core concepts deeply is more important than memorizing answers. Focus on building projects, contributing to open source, and staying curious about React's latest features and best practices.

← Back to JobScoutify