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

Props Destructuring

Learn how to extract values from props using JavaScript destructuring and write cleaner React functional components.

01 What Is Props Destructuring?

Props destructuring is a JavaScript technique that allows you to extract individual properties from the props object. Instead of repeatedly writing props.name, you can use name directly.

How Destructuring Works
Props Object { name, course, duration }
↓
name
course
duration
↓
Individual Variables Use values directly in JSX
Destructuring changes how you access props; it does not change the values or make props editable.
Expected Browser Output

Props properties can be extracted into individual variables.

02 Using Props Without Destructuring

First, see how a component accesses each value using the props object.

Student.jsx
function Student(props) {
    return (
        <div>
            <h2>{props.name}</h2>
            <p>Course: {props.course}</p>
            <p>City: {props.city}</p>
        </div>
    );
}

export default Student;
Expected Browser Output

Samadhan

Course: React JS

City: Pune

03 Destructuring Inside the Component

You can destructure props inside the component body by using an assignment statement.

Student.jsx
function Student(props) {
    const { name, course, city } = props;

    return (
        <div>
            <h2>{name}</h2>
            <p>Course: {course}</p>
            <p>City: {city}</p>
        </div>
    );
}

export default Student;

The statement const { name, course, city } = props; extracts these three properties into variables.

Expected Browser Output

Samiksha

Course: Full Stack Development

City: Pune

04 Destructuring Directly in Function Parameters

React functional components can destructure props directly in their function parameters. This is a common and concise pattern.

Student.jsx
function Student({ name, course, city }) {
    return (
        <div>
            <h2>{name}</h2>
            <p>Course: {course}</p>
            <p>City: {city}</p>
        </div>
    );
}

export default Student;
Parameter Destructuring
Parent Component Passes name, course and city
↓
Student({ name, course, city }) Extracts props in the parameter list
↓
JSX Output Displays the extracted values
Expected Browser Output

Pradnya

Course: Python

City: Pune

05 Passing Props from the Parent Component

The parent component passes values using JSX attributes. The child receives those values and destructures them.

App.jsx
function App() {
    return (
        <Student
            name="Samadhan"
            course="React JS"
            city="Pune"
        />
    );
}

function Student({ name, course, city }) {
    return (
        <div>
            <h2>{name}</h2>
            <p>Course: {course}</p>
            <p>City: {city}</p>
        </div>
    );
}

export default App;
Expected Browser Output

Samadhan

Course: React JS

City: Pune

06 Destructuring with Default Values

You can provide default values during destructuring. A default is used when the property is missing or its value is undefined.

Student.jsx
function Student({
    name = "Guest",
    course = "Not Assigned"
}) {
    return (
        <div>
            <h2>{name}</h2>
            <p>Course: {course}</p>
        </div>
    );
}

export default Student;

When the parent renders <Student />, the defaults are used.

Expected Browser Output

Guest

Course: Not Assigned

07 Destructuring Array and Object Props

You can destructure an object prop and then use its properties. Array props can also be received and processed in the component.

App.jsx
function App() {
    const student = {
        name: "Samiksha",
        course: "React JS"
    };

    const skills = ["HTML", "CSS", "JavaScript"];

    return (
        <Student details={student} skills={skills} />
    );
}

function Student({ details, skills }) {
    const { name, course } = details;

    return (
        <div>
            <h2>{name}</h2>
            <p>Course: {course}</p>

            <h3>Skills
        
Expected Browser Output

Samiksha

Course: React JS

Skills

  • HTML
  • CSS
  • JavaScript

08 Destructuring in Reusable Components

Destructuring makes reusable components easier to read because each component can access its required properties directly.

App.jsx
function App() {
    return (
        <div>
            <Course name="Java" duration="4 Months" />
            <Course name=".NET" duration="5 Months" />
            <Course name="Python" duration="3 Months" />
        </div>
    );
}

function Course({ name, duration }) {
    return (
        <div>
            <h3>{name}</h3>
            <p>Duration: {duration}</p>
        </div>
    );
}

export default App;
Reusable Component with Destructuring
App Passes different prop values
↓
Course { name, duration } Java · 4 Months
Course { name, duration } .NET · 5 Months
Course { name, duration } Python · 3 Months
Expected Browser Output

Java

Duration: 4 Months


.NET

Duration: 5 Months


Python

Duration: 3 Months

09 Props Destructuring vs props.property

Both approaches access the same prop values. Destructuring is often shorter when a component needs multiple properties.

Two Ways to Read Props
Without Destructuring props.name props.course
With Destructuring { name, course } name and course
Student.jsx
// Without destructuring
function StudentA(props) {
    return <p>{props.name} - {props.course}</p>;
}

// With destructuring
function StudentB({ name, course }) {
    return <p>{name} - {course}</p>;
}
Expected Browser Output

Samadhan - React JS

Samadhan - React JS

Both approaches produce the same output when given the same props.

10 Important Rules

  • Destructuring is a JavaScript feature.
  • You can destructure props inside the component or in its parameters.
  • Property names must match the names in the props object.
  • Default values can be provided during destructuring.
  • Destructuring does not make props mutable.
  • Use destructuring when it makes your component easier to read.
Expected Browser Output

This section describes React coding rules; it does not produce a separate rendered component.

Summary

Props destructuring is a JavaScript feature that extracts properties from an object into individual variables. In React, it lets functional components access props directly without repeatedly writing props.property. You can destructure strings, numbers, objects and arrays received through props, and you can provide default values for missing or undefined properties. Destructuring improves readability while keeping props read-only and supporting reusable components at CIIT Training Institute.