Skip to content
Home Interview React Interview Questions: Core Concepts Every Mid-Level Dev Must Know

React Interview Questions: Core Concepts Every Mid-Level Dev Must Know

Where developers are forged. · Structured learning · Free forever.
📍 Part of: JavaScript Interview → Topic 3 of 5
React interview questions explained deeply — covering hooks, state, reconciliation, and performance.
⚙️ Intermediate — basic Interview knowledge assumed
In this tutorial, you'll learn
React interview questions explained deeply — covering hooks, state, reconciliation, and performance.
  • React's efficiency comes from the Virtual DOM, which avoids expensive browser reflows by batching updates.
  • Reconciliation is the process where React diffs two virtual trees to determine the minimum number of changes needed for the Real DOM.
  • Keys are not just for suppressing console warnings; they are essential for React to track item identity across re-renders.
✦ Plain-English analogy ✦ Real code with output ✦ Interview questions
Quick Answer

Think of React like a smart whiteboard in a classroom. Instead of erasing and redrawing everything every time something changes, it only erases and redraws the parts that actually changed. That's React's whole superpower — it's incredibly efficient about what it updates on screen. The 'rules' React has (like hooks rules and component structure) are just the whiteboard's instructions for how to keep track of what changed and why.

React is the most popular front-end library in the world right now, and that means every JavaScript developer eventually walks into an interview room and faces React questions. The problem isn't that these questions are hard — it's that most developers know HOW React works but can't explain WHY it works that way. Interviewers can smell the difference in about 30 seconds. If you can only recite syntax, you'll get filtered out. If you can explain the reasoning behind design decisions, you get the offer.

React solves the messy problem of keeping your UI in sync with your data. Before React, developers manually poked at the DOM and prayed nothing got out of sync. React introduced a declarative model: you describe what the UI should look like given your current state, and React figures out the most efficient way to make it happen. It's the difference between telling someone 'make the button red' versus giving them step-by-step painting instructions every single time.

By the end of this article you'll be able to answer questions about the virtual DOM, reconciliation, hooks rules, controlled vs uncontrolled components, and performance optimization — and more importantly, you'll understand the reasoning deeply enough to handle follow-up questions you've never seen before. That's what actually passes interviews.

The Virtual DOM and Reconciliation: The Engine Under the Hood

The most common React interview question is 'What is the Virtual DOM?' but the follow-up 'How does reconciliation work?' is where most candidates stumble. React doesn't just refresh the page; it maintains a lightweight copy of the real DOM in memory. When state changes, React creates a new virtual tree and compares it (diffing) with the previous one.

Interviewers look for an understanding of the O(n) heuristic algorithm React uses. It assumes that two elements of different types will produce different trees and that a 'key' prop helps identify which elements are stable across renders. This prevents unnecessary re-renders and keep the UI snappy.

io/thecodeforge/react/ReconciliationDemo.jsx · JAVASCRIPT
123456789101112131415161718192021222324252627282930313233343536
import React, { useState } from 'react';

/**
 * TheCodeForgeReconciliation & Key Demo
 * This illustrates why 'keys' matter in the Virtual DOM.
 */
const ListManager = () => {
  const [items, setItems] = useState(['Docker', 'Kubernetes', 'Spring Boot']);

  const addTech = () => {
    // Adding to the start of the array to test React's diffing
    setItems(['React', ...items]);
  };

  return (
    <div className="p-4">
      <button 
        onClick={addTech} 
        className="bg-blue-500 text-white px-4 py-2 rounded"
      >
        Add React to Stack
      </button>
      <ul className="mt-4">
        {items.map((item, index) => (
          // BAD: Using index as key. React might lose state if items shift.
          // GOOD: Using the item string (or a unique ID) as the key.
          <li key={item} className="border-b py-1">
            {item}
          </li>
        ))}
      </ul>
    </div>
  );
};

export default ListManager;
▶ Output
Component renders a button that prepends 'React' to a list, using unique keys for efficient DOM updates.
🔥Forge Tip: Diffing Heuristics
In an interview, mention that while a full tree comparison is O(n³), React uses a heuristic O(n) approach. This shows you understand the engineering trade-offs behind the library's performance.
FeatureVirtual DOMReal DOM
Update SpeedBlazing fast (JavaScript objects)Slow (triggers browser layout/reflow)
Memory UsageLow (only in-memory objects)High (complex browser structures)
EfficiencyBatched updates via ReconciliationIndividual, manual manipulation
ConsistencyDeclarative (UI follows State)Imperative (UI must be manually poked)

🎯 Key Takeaways

  • React's efficiency comes from the Virtual DOM, which avoids expensive browser reflows by batching updates.
  • Reconciliation is the process where React diffs two virtual trees to determine the minimum number of changes needed for the Real DOM.
  • Keys are not just for suppressing console warnings; they are essential for React to track item identity across re-renders.
  • Answering 'Why' (design decisions) is more valuable than answering 'How' (syntax) in a mid-to-senior level interview.

⚠ Common Mistakes to Avoid

    Using array index as a 'key' prop for dynamic lists, causing hidden bugs in component state.
    Updating state directly (e.g., this.state.count = 1) instead of using the proper setter function, which breaks React's change detection.
    Neglecting to clean up side effects in useEffect, leading to memory leaks or orphaned event listeners.
    Confusing 'props' (immutable data from parents) with 'state' (internal mutable data managed by the component).

Frequently Asked Questions

What is the difference between a Controlled and Uncontrolled component?

A Controlled component has its value managed by React state; the single source of truth is the state variable. In an Uncontrolled component, the data is handled by the DOM itself, usually accessed via a Ref. Use controlled components for validation and real-time UI updates.

How does React's 'useEffect' handle component lifecycle events?

useEffect is a combined replacement for componentDidMount, componentDidUpdate, and componentWillUnmount. An empty dependency array [] mimics 'mount', an array with variables [data] mimics 'update' for those specific items, and returning a function from the effect handles the 'unmount' or cleanup phase.

What is 'lifting state up' in React?

Lifting state up is the pattern of moving state from a child component to its closest common ancestor when multiple child components need to share or synchronize that data. This maintains the 'unidirectional data flow' principle of React.

🔥
Naren Founder & Author

Developer and founder of TheCodeForge. I built this site because I was tired of tutorials that explain what to type without explaining why it works. Every article here is written to make concepts actually click.

← PreviousJavaScript Closures Interview QNext →Node.js Interview Questions
Forged with 🔥 at TheCodeForge.io — Where Developers Are Forged