Master React From Scratch

Clear, practical, and structured React lessons designed for beginners and developers.

COURSE SYLLABUS
1. Introduction to React
Introduction to React What Is React? Features of React Advantages of React Limitations of React Uses of React React vs JavaScript React Architecture
2. React Getting Started
Getting Started Introduction Prerequisites Installing Node.js and npm Creating a React Project with Vite React Project Structure Running React Application Your First React Application
3. JSX
JSX Introduction What Is JSX? JavaScript Expressions JSX Attributes Rendering JSX Elements JSX Children React Fragments JSX Rules and Best Practices JSX vs HTML
4. React Components
Components Introduction Functional Components Class Components Component Composition Reusable Components Component Tree Component Lifecycle Import and Export Components
5. React Props
Props Introduction What Are Props? Passing Props to Components Props Destructuring Default Props Values Children Props Typing Props with TypeScript Props vs State
6. React State
State Introduction What Is State? useState Hook Updating State Functional State Updates State with Objects State with Arrays State Immutability Lifting State Up
7. React Events
Events Introduction Handling Events Passing Arguments to Event Handlers Synthetic Events Form Events Keyboard and Mouse Events Event Propagation
8. Conditional Rendering
Conditional Rendering Introduction If-Else Rendering Ternary Operator Logical AND Operator Element Variables Preventing Rendering Multiple Conditions Conditional CSS Classes
9. Lists and Keys
Lists and Keys Introduction Rendering Lists with map() Understanding Keys Choosing Unique Keys Lists of Objects Filtering Lists Sorting Lists Empty Lists and Conditional Rendering
10. React Forms
Forms Introduction Handling Forms Controlled Components Uncontrolled Components Handling Input Fields Checkboxes and Radio Buttons Select and Textarea Form Validation Form Submission
11. React Hooks
Hooks Introduction useState Hook useEffect Hook Effect Dependencies and Cleanup useRef Hook useReducer Hook useMemo Hook useCallback Hook Custom Hooks Rules of Hooks
12. React Context API
Context API Introduction createContext useContext Context Provider Reading Context Updating Context Using Multiple Contexts Context API vs Props Context API Best Practices
13. React Routing
Routing Introduction Introduction to React Router Installing React Router BrowserRouter Setup Routes and Route Components Link and NavLink Programmatic Navigation URL Parameters and useParams Nested Routes Not Found Routes Protected Routes
14. API Integration
API Integration Introduction Fetch API Async/Await with API Calls Displaying API Data Loading and Error States Sending POST Requests API Error Handling Using Axios Custom Fetch Hook API Environment Variables
15. State Management
State Management Introduction Global State Prop Drilling Introduction to Redux Redux Core Concepts Redux Toolkit Store and Slices useSelector and useDispatch Async Operations with Redux Toolkit State Management Best Practices
16. React Performance
Performance Introduction Understanding Re-Renders Avoiding Unnecessary Re-Renders React.memo useMemo Optimization useCallback Optimization React Developer Tools and Profiler Lazy Loading Components Code Splitting Optimizing Large Lists Performance Best Practices

Features of React

Discover the important features of React, including reusable components, declarative UI, one-way data flow, JSX, Hooks, and efficient UI updates.

Learning objective: Understand the key features of React and learn how they are used to build maintainable and interactive web applications.

1. What Are the Features of React?

React provides features that help developers organise user interfaces, manage changing data, and create reusable UI elements. These features are useful for building applications such as course portals, dashboards, shopping websites, and student management systems.

For example, CIIT Training Institute can create a reusable course card and use the same component to display Java, Python, React, and .NET courses. Only the course information needs to change.

In simple words: React helps us divide a large interface into smaller components and manage how those components display data.

2. Main Features of React

This diagram groups some of React's important features and shows how they contribute to building an application.

🧩
Components

Divide the interface into reusable parts.

📊
Props and State

Pass information and manage changing values.

🔄
Rendering

Update the displayed interface when needed.

↓
🖥️
Interactive User Interface

Components work together to create the application screen.

Remember: This is a simplified conceptual diagram, not a strict execution sequence. React's rendering and update process depends on the application and its data.

3. Component-Based Architecture

React applications are built from components. Each component can represent a small part of a page, such as a navbar, button, course card, or student profile.

Components can be combined to create larger interfaces. Reusable components reduce duplication and make UI code easier to maintain.

Example: Reusable Course Component

function CourseCard({ name }) {
    return (
        <div>
            <h3>{name}</h3>
            <p>Learn with practical examples.</p>
        </div>
    );
}

function App() {
    return (
        <div>
            <CourseCard name="React" />
            <CourseCard name="Python" />
            <CourseCard name=".NET" />
        </div>
    );
}

export default App;

Expected Output

React

Learn with practical examples.


Python

Learn with practical examples.


.NET

Learn with practical examples.

Explanation: The same CourseCard component is used three times. Its name prop changes the course title, while the remaining structure is reused.

4. Declarative User Interface

React uses a declarative approach. Developers describe what the UI should display for the current data, and React handles rendering the required changes.

For example, we can display a welcome message based on a variable instead of manually changing the text of an HTML element.

Example

function Welcome() {
    const studentName = "Rahul";

    return (
        <h2>Welcome, {studentName}!</h2>
    );
}

export default Welcome;

Expected Output

Welcome, Rahul!

Key point: JSX describes the UI. React manages rendering it; you do not need to manually update the heading's DOM text.

5. One-Way Data Flow

In React, data commonly flows from a parent component to a child component through props. A child can notify its parent about an event by calling a function passed as a prop.

👨‍💻
Parent Component

Holds data and passes props to the child.

→
🧒
Child Component

Receives props and displays information.

Data usually flows down through props; callbacks can communicate events upward.

Example

function Student({ name }) {
    return <p>Student Name: {name}</p>;
}

function App() {
    return <Student name="Priya" />;
}

export default App;

Expected Output

Student Name: Priya

Explanation: The parent passes "Priya" to the child through the name prop. The child reads that value and displays it.

6. JSX Support

JSX is a syntax extension that lets developers describe UI elements using markup-like syntax inside JavaScript code. It is commonly used when writing React components.

Example

function Course() {
    const courseName = "React";

    return (
        <section>
            <h2>{courseName} Tutorial</h2>
            <p>Learn step by step.</p>
        </section>
    );
}

export default Course;

Expected Output

React Tutorial

Learn step by step.

Remember: Browsers do not execute JSX source directly. A typical React build setup transforms JSX into JavaScript that the browser can execute.

7. State and Interactive UI

React state stores information that can change while an application is running. When state updates, React can render the component again to show the current value.

Example: Counter

import { useState } from "react";

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

    return (
        <div>
            <p>Count: {count}</p>

            <button onClick={() => setCount(count + 1)}>
                Increase
            </button>
        </div>
    );
}

export default Counter;

Expected Initial Output

Count: 0

This is a static illustration of the initial output. The code example must run inside a React application for the button to work.

Explanation: useState(0) sets the initial count to zero. Calling setCount requests a state update, and React renders the latest count in the interface.

8. React Hooks

Hooks are functions that let function components use React features, such as state and effects. Common examples include useState, useEffect, and useRef.

📊
useState

Stores and updates component state.

🔄
useEffect

Synchronizes a component with external systems when needed.

📌
useRef

Holds a value between renders without triggering a render when it changes.

Important: Hooks must follow React's Rules of Hooks. They should be called at the top level of function components or custom Hooks, not inside conditions or loops.

9. Efficient UI Updates

React calculates how the rendered UI should change when component inputs or state updates. For web applications, React DOM applies the necessary changes to the browser DOM.

React uses reconciliation to compare its new rendering with the previous one and determine the updates needed. This helps developers describe UI changes without manually coordinating every DOM operation.

📝
Data Changes

State or props change.

⚙️
Reconciliation

React determines required UI updates.

🖥️
DOM Updates

The browser interface is updated as needed.

Remember: React does not guarantee that every component update is automatically faster than every alternative. Good component design and measurement still matter for performance.

10. React Features at a Glance

Feature Purpose Example
Components Divide UI into reusable parts. CourseCard
Declarative UI Describe the required UI for current data. Welcome message
Props Pass information into components. Course name
State Manage changing component information. Counter value
JSX Describe elements using markup-like syntax. Heading and paragraph
Hooks Use React features in function components. useState
Reconciliation Determine how the rendered UI should change. Updating counter output

Summary

  • React supports reusable, component-based user interfaces.
  • Declarative UI describes what should be displayed.
  • Props pass data from parent components to child components.
  • State manages information that changes over time.
  • JSX provides a convenient syntax for describing UI elements.
  • Hooks let function components use React features.
  • Reconciliation helps React determine the UI updates that are needed.