LearnThatStack Ace your next interview
Frontend Development

React.

Start free Change topic Change
Practice · Questions

All questions

Showing of 108
Beginner 20
01

What is the Virtual DOM and how does it work?

Visual

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
Visual

The Virtual DOM is a JavaScript representation of the actual DOM (Document Object Model). It's a programming concept where a "virtual" representation of the UI is kept in memory and synced with the "real" DOM.

How it works:

  1. When state changes occur, React creates a new virtual DOM tree
  2. React compares (diffs) the new virtual DOM tree with the previous virtual DOM tree
  3. React calculates the minimum changes needed to update the real DOM
  4. React applies only these necessary changes to the real DOM

This process is called reconciliation and makes React applications faster because manipulating the virtual DOM is much faster than manipulating the real DOM.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

What is JSX and why is it used in React?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

JSX (JavaScript XML) is a syntax extension for JavaScript that allows you to write HTML-like code within JavaScript. It makes React components more readable and easier to write.

JSX gets transpiled to React.createElement() calls by tools like Babel:

// JSX
const element = <h1>Hello, World!</h1>;

// Transpiled to
const element = React.createElement('h1', null, 'Hello, World!');

Benefits of JSX:

  • More intuitive and readable than React.createElement()
  • Allows mixing of HTML-like syntax with JavaScript expressions
  • Provides better error messages and warnings
  • Enables static type checking
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What's the difference between React elements and React components?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

React Element: A plain JavaScript object that describes what should appear on screen. It's the smallest building block of React apps.

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

React Component: A function or class that returns React elements. Components are reusable and can accept inputs (props).

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

// Class component
class Welcome extends React.Component {
  render() {
    return <h1>Hello, {this.props.name}</h1>;
  }
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

What are the differences between functional and class components?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Functional Components:

  • Simpler syntax
  • Use React Hooks for state and lifecycle methods
  • Better performance (less overhead)
  • Easier to test and debug
  • Preferred approach in modern React
function MyComponent(props) {
  const [count, setCount] = useState(0);
  
  return <div>{count}</div>;
}

Class Components:

  • More verbose syntax
  • Use this.state and lifecycle methods
  • Have access to this context
  • Legacy approach (still supported)
class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = { count: 0 };
  }
  
  render() {
    return <div>{this.state.count}</div>;
  }
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

How do you create a React component?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

There are two main ways to create React components:

1. Function Component (Recommended):

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

// Or using arrow function
const Welcome = (props) => {
  return <h1>Hello, {props.name}!</h1>;
};

2. Class Component:

class Welcome extends React.Component {
  render() {
    return <h1>Hello, {this.props.name}!</h1>;
  }
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

What are the rules of JSX?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Key JSX rules:

  1. Must return a single parent element or use React Fragment
  2. Use camelCase for attributes: className instead of class, onClick instead of onclick
  3. Close all tags: Self-closing tags must end with />
  4. Use curly braces for JavaScript expressions: {variable} or {expression}
  5. Boolean attributes: disabled={true} or just disabled
// Correct JSX
function MyComponent() {
  return (
    <div className="container">
      <img src="image.jpg" alt="Description" />
      <p>Count: {count}</p>
    </div>
  );
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

What is React Fragment and when would you use it?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

React Fragment lets you group multiple elements without adding an extra node to the DOM. It's useful when you need to return multiple elements from a component but don't want to wrap them in a div.

// Using React.Fragment
function MyComponent() {
  return (
    <React.Fragment>
      <h1>Title</h1>
      <p>Description</p>
    </React.Fragment>
  );
}

// Using short syntax
function MyComponent() {
  return (
    <>
      <h1>Title</h1>
      <p>Description</p>
    </>
  );
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

08

How do you conditionally render elements in React?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

There are several ways to conditionally render elements:

1. Ternary Operator:

function Greeting({ isLoggedIn }) {
  return (
    <div>
      {isLoggedIn ? <h1>Welcome back!</h1> : <h1>Please log in.</h1>}
    </div>
  );
}

2. Logical AND (&&):

function Notification({ hasMessages }) {
  return (
    <div>
      {hasMessages && <p>You have new messages!</p>}
    </div>
  );
}

3. If-else statements:

function UserStatus({ user }) {
  if (user.isAdmin) {
    return <AdminPanel />;
  } else if (user.isLoggedIn) {
    return <UserPanel />;
  } else {
    return <LoginForm />;
  }
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

09

How do you render lists in React?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Use the map() method to render lists, and always provide a unique key prop:

function TodoList({ todos }) {
  return (
    <ul>
      {todos.map(todo => (
        <li key={todo.id}>
          {todo.text}
        </li>
      ))}
    </ul>
  );
}

The key prop helps React identify which items have changed, been added, or removed, improving performance during re-renders.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

10

What are props in React?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Props (short for properties) are read-only inputs passed from parent components to child components. They allow data to flow down the component tree.

// Parent component
function App() {
  return <Welcome name="John" age={25} />;
}

// Child component
function Welcome(props) {
  return <h1>Hello, {props.name}! You are {props.age} years old.</h1>;
}

Props characteristics:

  • Read-only (immutable)
  • Passed from parent to child
  • Can be any JavaScript value (strings, numbers, objects, functions, etc.)
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

11

What is state in React?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

State is a built-in React object used to contain data that may change over the lifetime of a component. When state changes, the component re-renders.

import { useState } from 'react';

function Counter() {
  const [count, setCount] = useState(0);
  
  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={() => setCount(count + 1)}>
        Increment
      </button>
    </div>
  );
}

State characteristics:

  • Mutable (can be changed)
  • Local to the component
  • Triggers re-renders when updated
  • Should not be modified directly
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

12

What's the difference between props and state?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
Props State
Read-only Mutable
Passed from parent Local to component
Cannot be changed by component Can be changed by component
External data Internal data
Functional parameters Component memory
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

13

How do you handle events in React?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

React uses SyntheticEvents, which are wrappers around native events that provide consistent behavior across browsers:

function Button() {
  const handleClick = (event) => {
    event.preventDefault();
    console.log('Button clicked!');
    console.log('Event type:', event.type);
  };
  
  return (
    <button onClick={handleClick}>
      Click me
    </button>
  );
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

14

How do you prevent default behavior in React events?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Use the preventDefault() method on the event object:

function Form() {
  const handleSubmit = (event) => {
    event.preventDefault(); // Prevents form from submitting
    console.log('Form submitted');
  };
  
  return (
    <form onSubmit={handleSubmit}>
      <input type="text" />
      <button type="submit">Submit</button>
    </form>
  );
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

15

How do you pass parameters to event handlers?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

There are several ways to pass parameters:

1. Arrow function in JSX:

function ItemList({ items }) {
  const handleClick = (id) => {
    console.log('Clicked item:', id);
  };
  
  return (
    <div>
      {items.map(item => (
        <button key={item.id} onClick={() => handleClick(item.id)}>
          {item.name}
        </button>
      ))}
    </div>
  );
}

2. Bind method:

function ItemList({ items }) {
  const handleClick = (id, event) => {
    console.log('Clicked item:', id);
  };
  
  return (
    <div>
      {items.map(item => (
        <button key={item.id} onClick={handleClick.bind(null, item.id)}>
          {item.name}
        </button>
      ))}
    </div>
  );
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

16

What is useState hook and how do you use it?

Part of Pro
17

What are controlled vs uncontrolled components?

Part of Pro
18

What is Create React App and what does it provide?

Part of Pro
19

What is the difference between React and ReactDOM?

Part of Pro
20

What is lifting state up in React, and when do you need it?

Part of Pro
Intermediate 55
21

What are React Hooks?

Part of Pro
22

How do you pass data from child to parent component?

Part of Pro
23

What is the `key` prop and why is it important?

Part of Pro
24

What is prop drilling and how can you avoid it?

Part of Pro
25

What are SyntheticEvents in React?

Part of Pro
26

What are React lifecycle methods?

Part of Pro
27

Name the most commonly used lifecycle methods?

Part of Pro
28

What is componentDidMount and when is it used?

Part of Pro
29

What is componentWillUnmount and when is it used?

Part of Pro
30

What is useEffect hook and what are its use cases?

Part of Pro
31

What's the difference between useEffect with and without dependencies?

Part of Pro
32

What is useContext hook?

Part of Pro
33

What is useReducer hook and when should you use it?

Part of Pro
34

What are the rules of Hooks?

Part of Pro
35

What is useMemo hook and when should you use it?

Part of Pro
36

What is useCallback hook?

Part of Pro
37

What is useRef hook?

Part of Pro
38

What are custom Hooks?

Part of Pro
39

What is React Context and when should you use it?

Part of Pro
40

How do you create and consume Context?

Part of Pro
41

What are different ways to manage state in React?

Part of Pro
42

When should you use external state management libraries?

Part of Pro
43

What is React.memo and when should you use it?

Part of Pro
44

What is the difference between useMemo and React.memo?

Part of Pro
45

What is React.lazy and Suspense?

Part of Pro
46

What is code splitting in React?

Part of Pro
47

What are Error Boundaries in React?

Part of Pro
48

How do you handle errors in async operations?

Part of Pro
49

What is React Router and how do you use it?

Part of Pro
50

How do you handle route parameters in React Router?

Part of Pro
51

How do you implement protected routes?

Part of Pro
52

What's the difference between BrowserRouter and HashRouter?

Part of Pro
53

How do you handle form validation in React?

Part of Pro
54

How do you handle different form input types?

Part of Pro
55

How do you test React components?

Part of Pro
56

How do you test components with state and effects?

Part of Pro
57

How do you test async operations and API calls?

Part of Pro
58

How do you test components with Context?

Part of Pro
59

What alternatives exist to Create React App?

Part of Pro
60

What is the difference between development and production builds?

Part of Pro
61

How do you handle environment variables in React?

Part of Pro
62

What are some deployment strategies for React applications?

Part of Pro
63

What is React.StrictMode?

Part of Pro
64

What are React Portals?

Part of Pro
65

How do you handle forms with multiple inputs efficiently?

Part of Pro
66

What is useId hook?

Part of Pro
67

What is the Container/Presentational component pattern?

Part of Pro
68

How do you optimize images in React applications?

Part of Pro
69

How do you test custom hooks?

Part of Pro
70

What is Server-Side Rendering (SSR) vs Client-Side Rendering (CSR)?

Part of Pro
71

What is Static Site Generation (SSG)?

Part of Pro
72

How do you handle state persistence across page refreshes?

Part of Pro
73

What is the difference between useLayoutEffect and useEffect?

Part of Pro
74

What are the new features in React 19?

Part of Pro
75

What is hydration in React?

Part of Pro
Expert 33
76

What is Redux and how does it work with React?

Part of Pro
77

What is the Provider pattern?

Part of Pro
78

What are the new features in React 18?

Part of Pro
79

What is Component Composition and how does it compare to inheritance?

Part of Pro
80

What are Higher-Order Components (HOCs)?

Part of Pro
81

What is the Render Props pattern?

Part of Pro
82

What is the Forwarding Refs pattern?

Part of Pro
83

What are some common React performance optimization techniques?

Part of Pro
84

What are the best practices for optimizing large lists?

Part of Pro
85

What are the performance implications of Context?

Part of Pro
86

How do you create Error Boundaries with Hooks?

Part of Pro
87

What are Compound Components?

Part of Pro
88

How do you optimize React apps for production?

Part of Pro
89

What is React Fiber?

Part of Pro
90

What is Concurrent Mode in React?

Part of Pro
91

How do you implement drag and drop in React?

Part of Pro
92

How do you implement infinite scrolling in React?

Part of Pro
93

What is useTransition hook?

Part of Pro
94

What is useDeferredValue hook?

Part of Pro
95

What is useSyncExternalStore hook?

Part of Pro
96

What is the Compound Component pattern with Context?

Part of Pro
97

What is the Observer pattern in React?

Part of Pro
98

What is the State Reducer pattern?

Part of Pro
99

How do you measure React application performance?

Part of Pro
100

How do you implement undo/redo functionality?

Part of Pro
101

How do you implement optimistic updates?

Part of Pro
102

What are common security concerns in React applications?

Part of Pro
103

How do you handle authentication and authorization?

Part of Pro
104

How do you test components with complex user interactions?

Part of Pro
105

How do you implement and test error boundaries?

Part of Pro
106

What are React Server Components?

Part of Pro
107

What is the React Compiler?

Part of Pro
108

What is a stale closure in React hooks, and how do you fix it?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for React? Send them this set.
Pro · $10/mo

93 of 108 React answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git