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

Passing Props to Components

Learn how to pass data from a parent component to child components using props, with diagrams, examples and expected browser output.

01 What Are Props?

Props stands for properties. Props allow a parent component to send information to a child component. A child component receives this information through its props parameter.

Basic Props Flow
Parent Component: App Provides the student's name
↓
name="Samadhan"
↓
Child Component: Student Receives data using props.name
Remember: props are passed from parent to child. A child component should not directly modify the props it receives.

02 Passing a Single String Prop

A string can be passed by writing a property name and value inside the child component's opening tag.

App.jsx
function App() {
    return <Student name="Samadhan" />;
}

function Student(props) {
    return <h2>Student Name: {props.name}</h2>;
}

export default App;

How it works:

  • App is the parent component.
  • name="Samadhan" passes a string prop.
  • props.name reads that value in the child.
Expected Browser Output

Student Name: Samadhan

03 Passing Multiple Props

You can pass more than one prop to a component. For example, a student component can receive a name, course and duration.

App.jsx
function App() {
    return (
        <Student
            name="Samiksha"
            course="React JS"
            duration="3 Months"
        />
    );
}

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

export default App;
Multiple Props
App Parent component
↓
name="Samiksha" course="React JS" duration="3 Months"
↓
Student Reads all three props
Expected Browser Output

Samiksha

Course: React JS

Duration: 3 Months

04 Passing Numbers and Boolean Values

Use curly braces to pass JavaScript values such as numbers and booleans. A string written without curly braces is treated as text.

App.jsx
function App() {
    return (
        <Student
            name="Pradnya"
            age={22}
            enrolled={true}
        />
    );
}

function Student(props) {
    return (
        <div>
            <p>Name: {props.name}</p>
            <p>Age: {props.age}</p>
            <p>
                Status: {props.enrolled ? "Enrolled" : "Not Enrolled"}
            </p>
        </div>
    );
}

export default App;
Expected Browser Output

Name: Pradnya

Age: 22

Status: Enrolled

05 Passing an Array as Props

Arrays can also be passed as props. The child component can use the JavaScript map() method to display each item.

App.jsx
function App() {
    const skills = ["HTML", "CSS", "JavaScript"];

    return <Student name="Samadhan" skills={skills} />;
}

function Student(props) {
    return (
        <div>
            <h3>{props.name}'s Skills</h3>
            <ul>
                {props.skills.map((skill) => (
                    <li key={skill}>{skill}</li>
                ))}
            </ul>
        </div>
    );
}

export default App;
Expected Browser Output

Samadhan's Skills

  • HTML
  • CSS
  • JavaScript

06 Passing an Object as Props

An object groups related values into one structure. You can pass the complete object through a prop and access its properties inside the child component.

App.jsx
function App() {
    const student = {
        name: "Pradnya",
        course: "Full Stack Development",
        institute: "CIIT Training Institute"
    };

    return <Student details={student} />;
}

function Student(props) {
    return (
        <div>
            <h3>{props.details.name}</h3>
            <p>Course: {props.details.course}</p>
            <p>Institute: {props.details.institute}</p>
        </div>
    );
}

export default App;
Expected Browser Output

Pradnya

Course: Full Stack Development

Institute: CIIT Training Institute

07 Props in Reusable Components

Props make components reusable. Instead of creating a separate component for every course, create one Course component and pass different values to it.

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(props) {
    return (
        <div>
            <h3>{props.name}</h3>
            <p>Duration: {props.duration}</p>
        </div>
    );
}

export default App;
One Component, Different Data
App Parent component
↓
Course Java · 4 Months
Course .NET · 5 Months
Course Python · 3 Months
Expected Browser Output

Java

Duration: 4 Months


.NET

Duration: 5 Months


Python

Duration: 3 Months

08 Passing Props Through Components

Sometimes data is passed through an intermediate component before reaching the component that displays it. Passing props through multiple levels like this is often called prop drilling.

Component Data Flow
App name="Samiksha"
↓ name prop
Student Receives and forwards name
↓ name prop
StudentProfile Displays the name
App.jsx
function App() {
    return <Student name="Samiksha" />;
}

function Student(props) {
    return <StudentProfile name={props.name} />;
}

function StudentProfile(props) {
    return <h2>Welcome to CIIT, {props.name}!</h2>;
}

export default App;
Expected Browser Output

Welcome to CIIT, Samiksha!

09 Props Are Read-Only

Props should not be changed directly inside a child component. If a value needs to change in response to user interaction, React state is usually the appropriate approach.

Student.jsx
// Incorrect: do not modify props directly.

function Student(props) {
    // props.name = "Pradnya";

    return <h2>{props.name}</h2>;
}
The assignment is intentionally commented out. This example demonstrates what not to do without modifying the received prop.
Expected Browser Output

When the parent passes name="Samadhan":

Samadhan

The child displays the received value without modifying it.

10 Complete Props Example

This example combines strings, numbers and an array to display a student profile.

App.jsx
function App() {
    const skills = ["React JS", "JavaScript", "HTML"];

    return (
        <StudentProfile
            name="Samadhan"
            age={23}
            skills={skills}
        />
    );
}

function StudentProfile(props) {
    return (
        <div>
            <h2>Student Profile</h2>
            <p>Name: {props.name}</p>
            <p>Age: {props.age}</p>

            <h3>Skills</h3>
            <ul>
                {props.skills.map((skill) => (
                    <li key={skill}>{skill}</li>
                ))}
            </ul>
        </div>
    );
}

export default App;
Expected Browser Output

Student Profile

Name: Samadhan

Age: 23

Skills

  • React JS
  • JavaScript
  • HTML

Summary

Props are inputs that allow a parent component to pass data to a child component. They can contain strings, numbers, booleans, arrays, objects and functions. Components use props to display dynamic content and reuse the same UI with different data. Props should be treated as read-only, helping React applications remain predictable and maintainable at CIIT Training Institute.