1. Home
  2. Coding Notes
  3. React
  4. React Introduction
  1. Home
  2. Coding Notes
  3. React
  4. React Introduction
HTMLCSSJavaScriptPythonJavaC++React.jsSQLNext.jsNode.js
Underrated CoderUnderrated Coder
Underrated CoderUnderrated Coder
Resources
  • Coding Hub
    • DSA & System Design Live Classes (C++ & Java)
    • Full Stack Web Development with AI Integration Live Classes
    • AI & Machine Learning with GenAI Live Classes (Python)
  • Roadmap
  • DSA Sheet
  • Coding Notes
  • Coding Quiz
  • Online Compiler
  • Coder AI
Interview Preparation
  • 1:1 Mentorship
  • Interview Q&A
Community
  • Blog
  • Coder Community
Help & Support
  • Contact Us
  • Troubleshooting
  • Report a Bug
HTMLCSSJavaScriptPythonJavaC++React.jsSQLNext.jsNode.js
Outline
React IntroductionSetup & ViteJSX SyntaxVirtual DOMFunction ComponentsComponent TreeReact Fragments
Passing PropsDestructuring PropsChildren PropConditional RenderingList RenderingReact KeysCSS Modules
Event HandlingSynthetic EventsState BasicsuseState HookState BatchingObject StateArray State
useEffect HookDependency ArrayCleanup FunctionsData FetchingStrict Mode
useRef HookPassing Refs (forwardRef)useReducer HookCustom HooksuseId Hook
Prop Drilling ProblemContext APIuseContext HookRedux IntroZustand Alternative
React Router DOMRoute ParametersNested RoutesControlled InputsReact Hook Form
React.memouseMemo HookuseCallback HookCode Splitting (lazy)Bundle Size Optimization
React Server ComponentsClient ComponentsSuspense for Data FetchingNext.js App RouterServer ActionsuseTransition HookReact 19 Forms (useActionState)
React.js

React Introduction

Overview

React is a declarative, efficient, and flexible open-source JavaScript library for building highly interactive User Interfaces (UIs). Developed and maintained by Facebook (Meta), it has become the undeniable industry standard for front-end web development, powering applications from Instagram to Netflix.

Historically, web development required manually manipulating the Document Object Model (DOM) using vanilla JavaScript or jQuery. This imperative approach ('go find this button, change its text, add this class') became an absolute nightmare to maintain in large applications. React introduced a declarative paradigm: you simply describe what the UI should look like at any given moment, and React handles the complex DOM updates behind the scenes to make it happen.

Furthermore, React enforces a component-based architecture. Instead of building monolithic HTML pages, developers create small, isolated, reusable UI blocks (Components). This drastically accelerates development speed, ensures visual consistency, and allows engineering teams to work on massive codebases simultaneously without stepping on each other's toes.

Syntax

Imperative vs Declarative (The React Way)
jsx
// Imperative (Vanilla JS) - Micro-managing the DOM
const btn = document.createElement('button');
btn.innerText = 'Click Me';
btn.addEventListener('click', () => alert('Clicked!'));
document.getElementById('root').appendChild(btn);

// Declarative (React) - Describing the end state
function ModernButton() {
  return <button onClick={() => alert('Clicked!')}>Click Me</button>;
}

Common Pitfalls

  • Confusing React with a Framework: React is strictly a UI library, not a full-fledged framework like Angular or Next.js. Out of the box, it only handles rendering views. For routing, global state, or data fetching, you must stitch together third-party libraries (like React Router or React Query).

Interview Questions

What is the difference between a Library and a Framework in the context of React?

A library provides specific functionality that you can call upon whenever you want (you are in control of the flow). A framework dictates the entire architecture of the app and calls your code (Inversion of Control). React is a UI library; it only cares about rendering the view layer. You must combine it with other tools to build a full application.

What does it mean that React is 'Declarative'?

Declarative programming means you describe the desired outcome rather than the step-by-step instructions to achieve it. In React, you declare how a component should look based on its current state, and React automatically figures out the most efficient way to update the actual browser DOM to match that state.

Real-World Example

Building an E-Commerce Interface: In a real product company, the NavigationMenu might be maintained by one team, the ProductDetails by another, and the Shopping Cart by a third. React's component model makes this organizational structure technically possible and highly scalable.

example
jsx
// React allows us to break down a massive Amazon-like page into tiny reusable parts
function AmazonProductPage() {
  return (
    <div>
      <NavigationMenu />
      
      <main>
        <ProductImageGallery images={product.images} />
        <ProductDetails info={product.info} />
        
        {/* Reusable Button Component */}
        <AddToCartButton productId={product.id} />
      </main>
      
      <RecommendedProducts category={product.category} />
      <Footer />
    </div>
  );
}

Check Your Knowledge

Test your understanding of React Introduction with these quick questions.

Question 1

Which company originally created and actively maintains React?

Question 2

Is React considered a library or a framework?

Take React Quiz
Outline
React IntroductionSetup & ViteJSX SyntaxVirtual DOMFunction ComponentsComponent TreeReact Fragments
Passing PropsDestructuring PropsChildren PropConditional RenderingList RenderingReact KeysCSS Modules
Event HandlingSynthetic EventsState BasicsuseState HookState BatchingObject StateArray State
useEffect HookDependency ArrayCleanup FunctionsData FetchingStrict Mode
useRef HookPassing Refs (forwardRef)useReducer HookCustom HooksuseId Hook
Prop Drilling ProblemContext APIuseContext HookRedux IntroZustand Alternative
React Router DOMRoute ParametersNested RoutesControlled InputsReact Hook Form
React.memouseMemo HookuseCallback HookCode Splitting (lazy)Bundle Size Optimization
React Server ComponentsClient ComponentsSuspense for Data FetchingNext.js App RouterServer ActionsuseTransition HookReact 19 Forms (useActionState)
React.js

React Introduction

Overview

React is a declarative, efficient, and flexible open-source JavaScript library for building highly interactive User Interfaces (UIs). Developed and maintained by Facebook (Meta), it has become the undeniable industry standard for front-end web development, powering applications from Instagram to Netflix.

Historically, web development required manually manipulating the Document Object Model (DOM) using vanilla JavaScript or jQuery. This imperative approach ('go find this button, change its text, add this class') became an absolute nightmare to maintain in large applications. React introduced a declarative paradigm: you simply describe what the UI should look like at any given moment, and React handles the complex DOM updates behind the scenes to make it happen.

Furthermore, React enforces a component-based architecture. Instead of building monolithic HTML pages, developers create small, isolated, reusable UI blocks (Components). This drastically accelerates development speed, ensures visual consistency, and allows engineering teams to work on massive codebases simultaneously without stepping on each other's toes.

Syntax

Imperative vs Declarative (The React Way)
jsx
// Imperative (Vanilla JS) - Micro-managing the DOM
const btn = document.createElement('button');
btn.innerText = 'Click Me';
btn.addEventListener('click', () => alert('Clicked!'));
document.getElementById('root').appendChild(btn);

// Declarative (React) - Describing the end state
function ModernButton() {
  return <button onClick={() => alert('Clicked!')}>Click Me</button>;
}

Common Pitfalls

  • Confusing React with a Framework: React is strictly a UI library, not a full-fledged framework like Angular or Next.js. Out of the box, it only handles rendering views. For routing, global state, or data fetching, you must stitch together third-party libraries (like React Router or React Query).

Interview Questions

What is the difference between a Library and a Framework in the context of React?

A library provides specific functionality that you can call upon whenever you want (you are in control of the flow). A framework dictates the entire architecture of the app and calls your code (Inversion of Control). React is a UI library; it only cares about rendering the view layer. You must combine it with other tools to build a full application.

What does it mean that React is 'Declarative'?

Declarative programming means you describe the desired outcome rather than the step-by-step instructions to achieve it. In React, you declare how a component should look based on its current state, and React automatically figures out the most efficient way to update the actual browser DOM to match that state.

Real-World Example

Building an E-Commerce Interface: In a real product company, the NavigationMenu might be maintained by one team, the ProductDetails by another, and the Shopping Cart by a third. React's component model makes this organizational structure technically possible and highly scalable.

example
jsx
// React allows us to break down a massive Amazon-like page into tiny reusable parts
function AmazonProductPage() {
  return (
    <div>
      <NavigationMenu />
      
      <main>
        <ProductImageGallery images={product.images} />
        <ProductDetails info={product.info} />
        
        {/* Reusable Button Component */}
        <AddToCartButton productId={product.id} />
      </main>
      
      <RecommendedProducts category={product.category} />
      <Footer />
    </div>
  );
}

Check Your Knowledge

Test your understanding of React Introduction with these quick questions.

Question 1

Which company originally created and actively maintains React?

Question 2

Is React considered a library or a framework?

Take React Quiz

React Introduction — React.js Notes

React.js coding notes for Indian students — React Introduction. Syntax, pitfalls, and interview revision from Underrated Coder.

Overview

React is a declarative, efficient, and flexible open-source JavaScript library for building highly interactive User Interfaces (UIs). Developed and maintained by Facebook (Meta), it has become the undeniable industry standard for front-end web development, powering applications from Instagram to Netflix.

Historically, web development required manually manipulating the Document Object Model (DOM) using vanilla JavaScript or jQuery. This imperative approach ('go find this button, change its text, add this class') became an absolute nightmare to maintain in large applications. React introduced a declarative paradigm: you simply describe what the UI should look like at any given moment, and React handles the complex DOM updates behind the scenes to make it happen.

Furthermore, React enforces a component-based architecture. Instead of building monolithic HTML pages, developers create small, isolated, reusable UI blocks (Components). This drastically accelerates development speed, ensures visual consistency, and allows engineering teams to work on massive codebases simultaneously without stepping on each other's toes.

Syntax

Imperative vs Declarative (The React Way)

// Imperative (Vanilla JS) - Micro-managing the DOM
const btn = document.createElement('button');
btn.innerText = 'Click Me';
btn.addEventListener('click', () => alert('Clicked!'));
document.getElementById('root').appendChild(btn);

// Declarative (React) - Describing the end state
function ModernButton() {
  return <button onClick={() => alert('Clicked!')}>Click Me</button>;
}

Common pitfalls

  • Confusing React with a Framework: React is strictly a UI library, not a full-fledged framework like Angular or Next.js. Out of the box, it only handles rendering views. For routing, global state, or data fetching, you must stitch together third-party libraries (like React Router or React Query).

Interview questions

What is the difference between a Library and a Framework in the context of React?
A library provides specific functionality that you can call upon whenever you want (you are in control of the flow). A framework dictates the entire architecture of the app and calls your code (Inversion of Control). React is a UI library; it only cares about rendering the view layer. You must combine it with other tools to build a full application.
What does it mean that React is 'Declarative'?
Declarative programming means you describe the desired outcome rather than the step-by-step instructions to achieve it. In React, you declare how a component should look based on its current state, and React automatically figures out the most efficient way to update the actual browser DOM to match that state.

Real-world example

Building an E-Commerce Interface: In a real product company, the NavigationMenu might be maintained by one team, the ProductDetails by another, and the Shopping Cart by a third. React's component model makes this organizational structure technically possible and highly scalable.

// React allows us to break down a massive Amazon-like page into tiny reusable parts
function AmazonProductPage() {
  return (
    <div>
      <NavigationMenu />
      
      <main>
        <ProductImageGallery images={product.images} />
        <ProductDetails info={product.info} />
        
        {/* Reusable Button Component */}
        <AddToCartButton productId={product.id} />
      </main>
      
      <RecommendedProducts category={product.category} />
      <Footer />
    </div>
  );
}

React.js coding notes for Indian students — 53 topics with syntax, pitfalls, interview Q&A, and inline quizzes.

Topics in React.js

  1. React Introduction
  2. Setup & Vite
  3. JSX Syntax
  4. Virtual DOM
  5. Function Components
  6. Component Tree
  7. React Fragments
  8. Passing Props
  9. Destructuring Props
  10. Children Prop
  11. Conditional Rendering
  12. List Rendering
  13. React Keys
  14. CSS Modules
  15. Event Handling
  16. Synthetic Events
  17. State Basics
  18. useState Hook
  19. State Batching
  20. Object State
  21. Array State
  22. useEffect Hook
  23. Dependency Array
  24. Cleanup Functions
  25. Data Fetching
  26. Strict Mode
  27. useRef Hook
  28. Passing Refs (forwardRef)
  29. useReducer Hook
  30. Custom Hooks
  31. useId Hook
  32. Prop Drilling Problem
  33. Context API
  34. useContext Hook
  35. Redux Intro
  36. Zustand Alternative
  37. React Router DOM
  38. Route Parameters
  39. Nested Routes
  40. Controlled Inputs
  41. React Hook Form
  42. React.memo
  43. useMemo Hook
  44. useCallback Hook
  45. Code Splitting (lazy)
  46. Bundle Size Optimization
  47. React Server Components
  48. Client Components
  49. Suspense for Data Fetching
  50. Next.js App Router
  51. Server Actions
  52. useTransition Hook
  53. React 19 Forms (useActionState)

Study next

  • All coding notes
  • React.js notes home
  • React certification quiz
  • Online compiler
  • Interview Q&A

React Introduction — React.js Notes

React.js coding notes for Indian students — React Introduction. Syntax, pitfalls, and interview revision from Underrated Coder.

Overview

React is a declarative, efficient, and flexible open-source JavaScript library for building highly interactive User Interfaces (UIs). Developed and maintained by Facebook (Meta), it has become the undeniable industry standard for front-end web development, powering applications from Instagram to Netflix.

Historically, web development required manually manipulating the Document Object Model (DOM) using vanilla JavaScript or jQuery. This imperative approach ('go find this button, change its text, add this class') became an absolute nightmare to maintain in large applications. React introduced a declarative paradigm: you simply describe what the UI should look like at any given moment, and React handles the complex DOM updates behind the scenes to make it happen.

Furthermore, React enforces a component-based architecture. Instead of building monolithic HTML pages, developers create small, isolated, reusable UI blocks (Components). This drastically accelerates development speed, ensures visual consistency, and allows engineering teams to work on massive codebases simultaneously without stepping on each other's toes.

Syntax

Imperative vs Declarative (The React Way)

// Imperative (Vanilla JS) - Micro-managing the DOM
const btn = document.createElement('button');
btn.innerText = 'Click Me';
btn.addEventListener('click', () => alert('Clicked!'));
document.getElementById('root').appendChild(btn);

// Declarative (React) - Describing the end state
function ModernButton() {
  return <button onClick={() => alert('Clicked!')}>Click Me</button>;
}

Common pitfalls

  • Confusing React with a Framework: React is strictly a UI library, not a full-fledged framework like Angular or Next.js. Out of the box, it only handles rendering views. For routing, global state, or data fetching, you must stitch together third-party libraries (like React Router or React Query).

Interview questions

What is the difference between a Library and a Framework in the context of React?
A library provides specific functionality that you can call upon whenever you want (you are in control of the flow). A framework dictates the entire architecture of the app and calls your code (Inversion of Control). React is a UI library; it only cares about rendering the view layer. You must combine it with other tools to build a full application.
What does it mean that React is 'Declarative'?
Declarative programming means you describe the desired outcome rather than the step-by-step instructions to achieve it. In React, you declare how a component should look based on its current state, and React automatically figures out the most efficient way to update the actual browser DOM to match that state.

Real-world example

Building an E-Commerce Interface: In a real product company, the NavigationMenu might be maintained by one team, the ProductDetails by another, and the Shopping Cart by a third. React's component model makes this organizational structure technically possible and highly scalable.

// React allows us to break down a massive Amazon-like page into tiny reusable parts
function AmazonProductPage() {
  return (
    <div>
      <NavigationMenu />
      
      <main>
        <ProductImageGallery images={product.images} />
        <ProductDetails info={product.info} />
        
        {/* Reusable Button Component */}
        <AddToCartButton productId={product.id} />
      </main>
      
      <RecommendedProducts category={product.category} />
      <Footer />
    </div>
  );
}

React.js coding notes for Indian students — 53 topics with syntax, pitfalls, interview Q&A, and inline quizzes.

Topics in React.js

  1. React Introduction
  2. Setup & Vite
  3. JSX Syntax
  4. Virtual DOM
  5. Function Components
  6. Component Tree
  7. React Fragments
  8. Passing Props
  9. Destructuring Props
  10. Children Prop
  11. Conditional Rendering
  12. List Rendering
  13. React Keys
  14. CSS Modules
  15. Event Handling
  16. Synthetic Events
  17. State Basics
  18. useState Hook
  19. State Batching
  20. Object State
  21. Array State
  22. useEffect Hook
  23. Dependency Array
  24. Cleanup Functions
  25. Data Fetching
  26. Strict Mode
  27. useRef Hook
  28. Passing Refs (forwardRef)
  29. useReducer Hook
  30. Custom Hooks
  31. useId Hook
  32. Prop Drilling Problem
  33. Context API
  34. useContext Hook
  35. Redux Intro
  36. Zustand Alternative
  37. React Router DOM
  38. Route Parameters
  39. Nested Routes
  40. Controlled Inputs
  41. React Hook Form
  42. React.memo
  43. useMemo Hook
  44. useCallback Hook
  45. Code Splitting (lazy)
  46. Bundle Size Optimization
  47. React Server Components
  48. Client Components
  49. Suspense for Data Fetching
  50. Next.js App Router
  51. Server Actions
  52. useTransition Hook
  53. React 19 Forms (useActionState)

Study next

  • All coding notes
  • React.js notes home
  • React certification quiz
  • Online compiler
  • Interview Q&A