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

What Are Props in React?

Understand how React components receive data from parent components, use props to display dynamic information, and build reusable UI at CIIT Training Institute.

React Fundamentals Practical Examples Expected Output Included

01 Learning Objectives

After completing this lesson, you will be able to:

01
Define Props

Understand the purpose of props in React.

02
Identify Parent and Child

Understand how components communicate through props.

03
Display Dynamic Data

Use received values in JSX output.

04
Use Props Correctly

Follow the read-only rule and reuse components.

02 Definition of Props

Props stands for properties. In React, props are inputs passed from a parent component to a child component. The child uses these values to decide what content to render.

Remember: Props allow a component to receive data from outside itself. They make components reusable because the same component can display different content for different prop values.
Welcome.jsx JSX
function Welcome(props) {
    return (
        <h2>Welcome, {props.name}!</h2>
    );
}

export default Welcome;
App.jsx JSX
import Welcome from "./Welcome";

function App() {
    return <Welcome name="Samadhan" />;
}

export default App;
Expected Browser Output

Welcome, Samadhan!

03 Parent and Child Components

A parent component can pass values to a child through JSX attributes. React makes those values available to the child through its props parameter.

PARENT COMPONENT App name="Samiksha"
↓
Passes a prop
↓
CHILD COMPONENT Welcome props.name
↓
RENDERED UI Welcome, Samiksha!
App.jsx JSX
function Welcome(props) {
    return <h2>Welcome, {props.name}!</h2>;
}

function App() {
    return <Welcome name="Samiksha" />;
}

export default App;
Expected Browser Output

Welcome, Samiksha!

The parent passes the name value to the Welcome component.

04 Accessing Props in a Component

A function component can receive a props object as its parameter. You can access individual values using dot notation, such as props.name and props.course.

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

export default StudentInfo;
App.jsx JSX
import StudentInfo from "./StudentInfo";

function App() {
    return (
        <StudentInfo
            name="Pradnya"
            course="React JS"
        />
    );
}

export default App;
Expected Browser Output

Pradnya

Course: React JS

05 Different Types of Prop Values

Props can contain strings, numbers, booleans, arrays, objects, functions and other JavaScript values. Use quotation marks for string attributes and curly braces for JavaScript expressions.

CourseInfo.jsx JSX
function CourseInfo(props) {
    return (
        <div>
            <h2>{props.name}</h2>
            <p>Duration: {props.months} months</p>
            <p>Online: {props.isOnline ? "Yes" : "No"}</p>
        </div>
    );
}

export default CourseInfo;
App.jsx JSX
import CourseInfo from "./CourseInfo";

function App() {
    return (
        <CourseInfo
            name="React JS"
            months={3}
            isOnline={true}
        />
    );
}

export default App;
Expected Browser Output

React JS

Duration: 3 months

Online: Yes

Important: months={3} passes a number, while months="3" passes a string. Use curly braces when passing JavaScript values or expressions.

06 Props Make Components Reusable

A single component can be rendered several times with different props. This avoids duplicating the same component structure for every student or course.

StudentCard.jsx JSX
function StudentCard(props) {
    return (
        <div>
            <h3>{props.name}</h3>
            <p>Course: {props.course}</p>
        </div>
    );
}

export default StudentCard;
App.jsx JSX
import StudentCard from "./StudentCard";

function App() {
    return (
        <section>
            <h2>CIIT Student Profiles</h2>

            <StudentCard
                name="Samadhan"
                course="React JS"
            />

            <StudentCard
                name="Samiksha"
                course=".NET Full Stack"
            />

            <StudentCard
                name="Pradnya"
                course="Python"
            />
        </section>
    );
}

export default App;
Expected Browser Output

CIIT Student Profiles

Samadhan Course: React JS
Samiksha Course: .NET Full Stack
Pradnya Course: Python

07 Props Are Read-Only

React components should not modify the props they receive. If a value needs to change, the parent should pass updated data, or the component should use state for its own changing data.

Greeting.jsx JSX
function Greeting(props) {
    return (
        <div>
            <h2>Hello, {props.name}!
            <p>Welcome to CIIT Training Institute.</p>
        </div>
    );
}

export default Greeting;
Best Practice: Read the value using props.name, but do not assign a new value to props.name. Treat props as read-only inputs to keep component behaviour predictable.
Expected Browser Output

Hello, Samiksha!

Welcome to CIIT Training Institute.

08 Props vs Hardcoded Values

A hardcoded component displays fixed content. A component that uses props can display different content without changing the component's internal code.

Hardcoded Component Component Using Props
Displays fixed content. Displays content supplied by the parent.
Needs code changes to show another name. Can display another name by receiving a new prop.
Less flexible for repeated UI. Supports reusable UI with different data.
Welcome.jsx JSX
function Welcome(props) {
    return <h2>Welcome, {props.name}!</h2>;
}

export default Welcome;
Expected Browser Output

Using <Welcome name="Samadhan" />:

Welcome, Samadhan!

Using <Welcome name="Pradnya" />:

Welcome, Pradnya!

09 Common Props Mistakes

1. Incorrect Prop Name

Ensure the attribute name passed by the parent matches the property accessed by the child.

<Welcome name="Samadhan" />

2. Passing a Number as a String

Use curly braces when you need to pass a number rather than a string.

<Student marks={80} />

3. Modifying Props

Props are read-only. Do not assign a new value to a prop inside the child component.

return <p>{props.name}</p>;

4. Forgetting to Pass a Required Value

If a component expects a value, make sure the parent provides it or the component has a suitable fallback.

<StudentInfo name="Pradnya" />

10 Practice Questions

  1. What are props in React?
  2. How does a parent component pass data to a child component?
  3. Create a Welcome component that accepts a name prop.
  4. Pass a number and a boolean to a component.
  5. Create a CourseInfo component with name and duration props.
  6. Build reusable StudentCard components for Samadhan, Samiksha and Pradnya.
  7. Why should a component treat props as read-only?

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.