Exambodh - Practice Aptitude, Reasoning & GK Questions

Back to Articles
React jsReact Interview

Core React Interview Questions Every Developer Should Know

React js·

Share Article

Share this article on social platforms or copy the direct link.

React Interview Series

Core React Concepts

Master the 6 essential React fundamentals every developer must know — clear explanations, real code examples, and interview tips.

1
Fundamental Must Know

What is React and how does it differ from other frameworks?

Library vs Framework · UI Layer · Ecosystem

⚛️

Quick Answer

React is an open-source JavaScript library developed by Meta (Facebook) for building User Interfaces. It focuses only on the View layer — routing, state management, and API calls require separate libraries.

React vs Angular vs Vue

Feature⚛️ ReactAngularVue
TypeLibrary (UI only)Full FrameworkProgressive Framework
DOMVirtual DOMReal DOMVirtual DOM
LanguageJSX (JS + HTML)TypeScriptHTML Template + JS
Learning CurveMediumHighLow
Created byMetaGoogleEvan You

React's Core Strengths

🧩
Component-Based
Build reusable, isolated UI pieces
Virtual DOM
Fast, efficient UI updates
🌊
One-Way Data Flow
Predictable state management
🎣
Hooks API
State & effects in functions
🌍
Huge Ecosystem
Next.js, Redux, React Native
📱
Cross-Platform
Web & Mobile (React Native)
💡

Interview Tip

Always emphasize that React is a library, not a framework. Angular is "opinionated" (forces one way to do things) while React gives you full freedom to choose your own tools for routing, state, etc.

2
Performance Most Asked

What is the Virtual DOM and how does it work?

Diffing · Reconciliation · Performance Optimization

🧠

Quick Answer

The Virtual DOM is a lightweight JavaScript representation of the real DOM kept in memory. When state changes, React updates the Virtual DOM first, compares it with the previous version (diffing), and applies only the minimal necessary changes to the actual DOM.

Step-by-Step Process

1

Initial Render

React creates a Virtual DOM tree — a complete JavaScript object representing the entire UI structure.

2

State / Props Change

When useState or setState is called, React creates a brand new Virtual DOM tree reflecting the updated state.

3

Diffing Algorithm

React compares the old and new Virtual DOM trees using its optimized diffing algorithm to detect what changed.

4

Reconciliation

Only the changed nodes are patched in the actual DOM — making updates extremely fast and efficient.

Visual Flow

State Change
setCount(5)
New Virtual DOM
JS Object (new)
Diffing
Compare old vs new
Real DOM
Only diff applied ✓
💡

Interview Tip: Mention Reconciliation and the Fiber architecture (React 16+). Fiber improved the diffing algorithm to be interruptible, enabling Concurrent Mode and Suspense.

3
Syntax Core Concept

What is JSX? Why do we use it?

JavaScript XML · Babel · Syntax Sugar

📝

Quick Answer

JSX (JavaScript XML) is a syntax extension that lets you write HTML-like markup inside JS code. Babel transpiles it into React.createElement() calls under the hood.

With JSX — Clean ✓

JSX
// Clean and readable
const el = (
  <div className="card">
    <h1>Hello, {name}!</h1>
    <p>Welcome</p>
  </div>
);

Without JSX — Verbose

Pure JS
// Same output — messy!
const el = React.createElement(
  'div',
  { className: 'card' },
  React.createElement(
    'h1', null, 'Hello, ', name
  ),
  React.createElement(
    'p', null, 'Welcome'
  )
);

Important JSX Rules

Use className instead of class (JS reserved word)

Use htmlFor instead of for in labels

Must return a single root element — use <>...</> Fragment to avoid extra DOM nodes

JavaScript expressions go inside {curly braces}

Self-closing tags must close: <img />, <br />

💡

Interview Tip: JSX is not HTML — it compiles to React.createElement(). In React 17+, you no longer need to import React thanks to the new JSX transform.

4
Architecture Must Know

What are Components? Functional vs Class Components?

Building Blocks · Hooks · Lifecycle · Modern React

🧱

Quick Answer

Components are the building blocks of any React app. Each component is an independent, reusable piece of UI with its own logic — like LEGO bricks, small, self-contained, and composable.

Functional ComponentModern ✓
  • Plain JavaScript function
  • Uses Hooks (useState, useEffect)
  • Less code, more readable
  • Recommended in 2024+
Class ComponentLegacy
  • Extends React.Component
  • Uses this.state & lifecycle
  • More verbose boilerplate
  • Found in older codebases

Functional Component (recommended)

Counter.jsx
// ✅ Modern Functional Component with Hook
import { useState } from 'react';
 
function Counter({ title }) {
  const [count, setCount] = useState(0);
 
  return (
    <div className="counter">
      <h2>{title}</h2>
      <p>Count: {count}</p>
      <button onClick={() => setCount(c => c + 1)}>Increment</button>
    </div>
  );
}
export default Counter;

Class Component (legacy)

Counter.jsx (class)
// 🕰️ Class Component — older codebases
import { Component } from 'react';
 
class Counter extends Component {
  constructor(props) {
    super(props);
    this.state = { count: 0 };
  }
  render() {
    return (
      <div>
        <h2>{this.props.title}</h2>
        <p>Count: {this.state.count}</p>
      </div>
    );
  }
}
💡

Interview Tip: Say "In modern React, we use Functional Components exclusively with Hooks." Hooks solved all Class component use cases in a simpler, more composable way.

5
Data Flow Very Important

What is the difference between Props and State?

Parent-Child · Read-Only · Reactivity · Re-render

📦

Props (Properties)

Data passed from parent to child. The component receives them but cannot modify them. Props are read-only.

<Button color="blue" />
🔄

State

Data managed inside the component itself. It can change over time. Every state change triggers a re-render.

const [count, setCount] = useState(0)
Props vs State — Complete Example
// Parent component — passes PROPS down
function App() {
  return <LikeButton label="Like this post" postId={42} />;
}
 
// Child component — receives PROPS, manages own STATE
function LikeButton({ label, postId }) {          // ← PROPS
  const [liked, setLiked] = useState(false);     // ← STATE
  const [count, setCount] = useState(0);        // ← STATE
 
  const handleLike = () => {
    setLiked(true);
    setCount(c => c + 1);
  };
 
  return (
    <button onClick={handleLike}>
      {liked ? '❤️' : '🤍'} {label} ({count})
    </button>
  );
}
AspectPropsState
SourceFrom parent componentInternal to component
Mutable?No — Read-onlyYes — via setter
Re-render?When parent re-rendersOn every change
Declared with<Comp value={...} />useState(initial)
💡

Interview Tip: Mention "single source of truth" and "lifting state up". If two sibling components need the same data, move the state up to their common parent and pass it down as props.

6
Forms Common in Interviews

What is a Controlled vs Uncontrolled Component?

Forms · useRef · useState · Single Source of Truth

Controlled

Recommended ✓

React controls the form data via state. Every keystroke updates state, and state drives the displayed value.

Uncontrolled

Special Cases

The DOM manages the data itself. React reads the value only when needed using useRef.

Controlled

Controlled.jsx
function LoginForm() {
  const [email, setEmail] =
    useState('');
 
  return (
    <input
      type="email"
      value={email}
      onChange={e =>
        setEmail(e.target.value)
      }
    />
  );
  // React = source of truth
}

Uncontrolled

Uncontrolled.jsx
function FileUpload() {
  const fileRef =
    useRef(null);
 
  const submit = () => {
    console.log(
      fileRef.current
        .files[0]
    );
  };
 
  return (
    <input type="file"
      ref={fileRef} />
  );
  // DOM = source of truth
}
AspectControlledUncontrolled
Data lives inReact StateDOM itself
Access viastate variableref.current.value
ValidationReal-timeOn submit only
Best forText inputs, selectsFile upload, 3rd-party
Recommended?Yes ✓Special cases only
💡

Interview Tip: Always default to Controlled components. Libraries like React Hook Form and Formik use uncontrolled refs internally for performance, but expose a controlled-like API to developers.

What's Next?

Continue your React interview prep with these essential topics.

More In React js

Explore more React js articles

Read more articles from the same category or open the full category archive directly.