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

React vs JavaScript

Understand the relationship between JavaScript and React, how they differ, and when a developer might choose to use React for building an interactive user interface.

Learning objective: Learn what JavaScript does, what React adds, and how both work together in modern web development.

1. What Is the Difference?

JavaScript is a programming language used to add logic, interactivity, and behaviour to websites and applications.

React is a JavaScript library used to build user interfaces. It provides a component-based approach for describing the UI and managing updates when component data changes.

Therefore, React and JavaScript are not competing languages. React uses JavaScript, and a React application still relies on JavaScript for its logic.

In simple words: JavaScript is the programming language. React is a library built around JavaScript that helps developers organize and render user interfaces.

2. Relationship Between JavaScript and React

This simplified diagram shows how JavaScript and React fit together when building a web application.

💻
JavaScript

Programming language for logic, calculations, data handling, and browser behaviour.

+
⚛️
React

JavaScript library for components, declarative UI, props, and state.

↓
🖥️
Web Application

JavaScript and React work together to provide application logic and an interactive user interface.

Remember: React does not replace JavaScript. React applications use JavaScript, and JSX is typically transformed into JavaScript by the project's development or build tools.

3. JavaScript vs React Comparison

Aspect JavaScript React
What is it? A programming language. A JavaScript library for user interfaces.
Main purpose Programming logic and application behaviour. Building and rendering component-based interfaces.
DOM updates Can update DOM elements directly using browser APIs. React manages rendering and UI updates for the interface it controls.
Component system Does not provide React's component model by itself. Provides a component-based approach to UI development.
State management Can store values in variables and objects. Provides features such as state Hooks for reactive component updates.
Reusable UI Can be organized using functions and modules. Components are designed to be reusable UI units.
Required to learn React? Yes. JavaScript fundamentals are essential. Learn after understanding JavaScript fundamentals.
Typical use Scripts, calculations, browser interactions, and application logic. Interactive interfaces, dashboards, forms, and data-driven screens.

4. Example Using Plain JavaScript

Suppose we want to show a welcome message when a user clicks a button. With plain JavaScript, we can select an HTML element, listen for a click, and update its text.

HTML

<button id="welcomeButton">
    Show Welcome
</button>

<p id="message"></p>

JavaScript

const button = document.getElementById("welcomeButton");
const message = document.getElementById("message");

if (button && message) {
    button.addEventListener("click", () => {
        message.textContent =
            "Welcome to CIIT Training Institute!";
    });
}

Expected Behaviour

Before clicking

No welcome message is displayed.


After clicking

Welcome to CIIT Training Institute!

Explanation: JavaScript selects elements through the DOM and explicitly updates the paragraph's text when the button is clicked.

5. Example Using React

In React, the same kind of interaction can be implemented with component state. The UI is described using JSX, and React renders the current state value.

React Code

import { useState } from "react";

function WelcomeMessage() {
    const [showMessage, setShowMessage] = useState(false);

    return (
        <div>
            <button onClick={() => setShowMessage(true)}>
                Show Welcome
            </button>

            {showMessage && (
                <p>Welcome to CIIT Training Institute!</p>
            )}
        </div>
    );
}

export default WelcomeMessage;

Expected Behaviour

Initial State

showMessage = false

Only the button is displayed.


After Clicking

showMessage = true

Welcome to CIIT Training Institute!

Explanation:
  • useState(false) sets the initial value.
  • The button click changes the state to true.
  • The && condition controls whether the message is included in the UI.
  • React renders the component again to reflect the updated state.

6. Main Difference in the Examples

💻
Plain JavaScript
  • Select the HTML elements.
  • Register the click handler.
  • Manually update the message text.
⚛️
React
  • Store the message visibility in component state.
  • Change state when the button is clicked.
  • Describe the message using JSX and let React render it.
Important: Both approaches can build interactive interfaces. React is especially useful when an application has many components and data-driven UI updates to manage. For small tasks, plain JavaScript may be sufficient.

7. When Should You Use JavaScript or React?

Plain JavaScript May Be Suitable For
  • Small scripts and calculations.
  • Simple button and DOM interactions.
  • Small pages with limited UI complexity.
  • Tasks that do not need a full component-based UI structure.
React May Be Suitable For
  • Large interactive user interfaces.
  • Reusable course cards and shared components.
  • Applications with changing data and state.
  • Interfaces that benefit from component-based organization.

Summary

  • JavaScript is a programming language.
  • React is a JavaScript library for building user interfaces.
  • JavaScript can manipulate the DOM directly through browser APIs.
  • React provides components and declarative rendering for managing UI updates.
  • Both approaches can build interactive websites.
  • JavaScript fundamentals are essential for learning React.
  • Choose an approach according to the application's complexity and requirements.