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 Architecture

Understand how React applications are structured, how components work together, and how data flows from the application to the user interface.

1. What Is React Architecture?

React architecture describes how a React application is organized into components and how those components work together to build the user interface.

A typical React application has an entry point, a root component, reusable child components, data passed through props, and state that manages changing information.

Remember: React applications are usually built as a component tree. Each component is responsible for a particular part of the UI.

2. React Architecture Diagram

Follow the flow from the application entry point to the components rendered on the screen.

Entry Point

main.jsx

Starts the React application

↓ Renders the root component
Root Component

App.jsx

Defines the main application UI

↓ Uses child components

Header

Navigation area

CourseList

Displays courses

Footer

Bottom information

↓ React updates the UI when needed

Browser UI

What the user sees on the screen

Entry point Root component Child components

3. Main Parts of React Architecture

1

Entry Point

The entry point is usually main.jsx. It connects the React application to an HTML element and renders the root component.

2

Root Component

The App.jsx component is commonly used as the root component. It organizes the main application layout and child components.

3

Reusable Components

Components such as Header, Footer and CourseCard separate the interface into small, manageable parts.

4

Props and State

Props pass information to child components. State stores information that can change over time and cause the UI to update.

4. Example Project Structure

A simple React project created using Vite may contain files organized like this:

📁 my-react-app
📁 public
📁 src
📄 main.jsx
📄 App.jsx
📄 App.css
📁 components
📄 Header.jsx
📄 CourseCard.jsx
📄 index.html
📄 package.json
Note: This is an example structure. A project may contain additional files and folders depending on its requirements.

5. Example: main.jsx

The main.jsx file finds the HTML element with the ID root and renders the App component inside it.

main.jsx JSX
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.jsx';

createRoot(document.getElementById('root')).render(
    <StrictMode>
        <App />
    </StrictMode>
);

Code Explanation

  • StrictMode helps identify potential problems during development.
  • createRoot() creates a React root for the HTML element.
  • App is the root component rendered by React.
  • render() displays the component in the root element.

6. Example: App.jsx with Child Components

In this example, App uses separate components for the header, course list and footer.

App.jsx JSX
function Header() {
    return <h2>CIIT Training Institute</h2>;
}

function CourseList() {
    return (
        <div>
            <p>Java Full Stack</p>
            <p>Python Full Stack</p>
            <p>React Development</p>
        </div>
    );
}

function Footer() {
    return <p>Learn. Practice. Grow.</p>;
}

function App() {
    return (
        <div>
            <Header />
            <CourseList />
            <Footer />
        </div>
    );
}

export default App;
Expected Browser Output

CIIT Training Institute

Java Full Stack

Python Full Stack

React Development


Learn. Practice. Grow.

Important: The Header, CourseList, Footer and App functions are components. In this simple example, all components are defined in one file for learning purposes. In larger projects, they can be stored in separate files.

7. How Data Flows in React

React generally follows one-way data flow. A parent component can pass information to a child component through props. A child can notify a parent about an event using a callback function passed through props.

Parent Component

Owns the data

↓ Props

Child Component

Receives and displays data

↑ Callback function (when needed)

Parent Handles Event

Can update its state

Simple Props Example

App.jsx JSX
function CourseCard({ name }) {
    return <h3>Course: {name}</h3>;
}

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

export default App;
Expected Output:

Course: React Development

8. How React Updates the UI

When a component's state changes, React can render the component again. React compares the newly calculated UI with its previous representation and applies the necessary updates to the DOM.

1

User Action

The user clicks a button.

2

State Update

The component updates its state.

3

Re-render

React runs the component again.

4

UI Update

The required DOM changes are applied.

Remember: A state update does not mean that the entire browser DOM is replaced. React determines which changes are needed.

9. Benefits of Component-Based Architecture

Benefit Explanation
Reusability The same component can be used in multiple places.
Maintainability Smaller components are easier to understand and update.
Separation of Concerns Each component can manage a specific part of the UI.
Testability Individual components can be tested in isolation.
Scalability A clear structure helps organize growing applications.

Summary

  • React applications are organized using components.
  • main.jsx commonly provides the entry point.
  • App.jsx is commonly used as the root component.
  • Props pass information from parent components to child components.
  • State manages changing data and can trigger re-renders.
  • React updates the DOM as needed when the rendered UI changes.
  • Component-based architecture improves reuse and maintainability.