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

Reusable Components in React

Learn to create reusable React components using props, consistent UI patterns and practical examples from CIIT Training Institute.

Beginner Friendly Practical Examples Expected Output Included

01 Learning Objectives

After completing this lesson, you will be able to:

01
Understand Reusability

Write a component once and use it multiple times.

02
Pass Data with Props

Customize component content through props.

03
Reduce Repeated Code

Keep your application easier to maintain.

04
Build Reusable UI

Create course cards, student cards and buttons.

02 What Are Reusable Components?

A reusable component is a component that can be rendered in different places with different data. Instead of writing separate markup for every course or student, we create one component and customize it using props.

Remember: Write the UI structure once, then reuse it with different props wherever required.
CourseCard.jsx JSX
function CourseCard({ title, duration }) {
    return (
        <div>
            <h3>{title}</h3>
            <p>Duration: {duration}</p>
        </div>
    );
}

export default CourseCard;

The same CourseCard component can display React JS, .NET Full Stack and Python course details.

Expected Browser Output

React JS

Duration: 3 Months

.NET Full Stack

Duration: 6 Months

Python

Duration: 4 Months

03 Reusable Component Diagram

The parent component sends different props to the same reusable component. Each instance renders its own content.

CIIT TRAINING INSTITUTE — REUSABILITY FLOW
PARENT COMPONENT App() Provides different course props
INSTANCE 1 CourseCard React JS
INSTANCE 2 CourseCard .NET Full Stack
INSTANCE 3 CourseCard Python
One component + different props = multiple customized UI instances.
App.jsx JSX
import CourseCard from "./CourseCard";

function App() {
    return (
        <div>
            <h2>CIIT Training Courses</h2>

            <CourseCard
                title="React JS"
                duration="3 Months"
            />

            <CourseCard
                title=".NET Full Stack"
                duration="6 Months"
            />

            <CourseCard
                title="Python"
                duration="4 Months"
            />
        </div>
    );
}

export default App;
Expected Browser Output

CIIT Training Courses

React JS

Duration: 3 Months

.NET Full Stack

Duration: 6 Months

Python

Duration: 4 Months

04 Reusable Student Card

We can reuse one student component to display multiple students with different names and courses.

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

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

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

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

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

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

export default App;
Expected Browser Output

CIIT Student Profiles

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

05 Creating a Reusable Button

A reusable button component can accept its label and button type through props. Here we use a click handler passed from the parent component.

ActionButton.jsx JSX
function ActionButton({ label, onClick }) {
    return (
        <button type="button" onClick={onClick}>
            {label}
        </button>
    );
}

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

function App() {
    const showMessage = () => {
        alert("Welcome to CIIT Training Institute!");
    };

    return (
        <div>
            <ActionButton
                label="Start Learning"
                onClick={showMessage}
            />

            <ActionButton
                label="Contact Institute"
                onClick={showMessage}
            />
        </div>
    );
}

export default App;
Expected Browser Output

These are visual examples. In the running React app, clicking either button displays the configured alert.

06 Benefits of Reusable Components

01

Less Repeated Code

Write the structure once and reuse it.

02

Consistency

Keep the same UI structure across the application.

03

Easy Maintenance

Update a shared component in one place.

04

Flexible UI

Customize component instances using props.

07 Important Rules and Best Practices

✓

Use props to customize reusable components.

✓

Keep components focused on one clear responsibility.

✓

Pass event handlers as props when components need to respond to user actions.

✓

Avoid duplicating the same markup in multiple places.

✓

Use descriptive names such as StudentCard and CourseCard.

08 Practice Questions

  1. Create a reusable CourseCard component with title and duration props.
  2. Display three students using one StudentCard component.
  3. Create a reusable button that accepts a label prop.
  4. Create a reusable profile card that accepts name and role props.
  5. Explain how reusable components reduce repeated code.
  6. Build a course listing page using reusable components.

Summary

Reusable Components allow developers to define a UI structure once and render it in multiple places with different props. They reduce duplicated code, improve consistency and simplify maintenance. At CIIT Training Institute, practise reusability by creating course cards, student profiles and buttons that can be customized with different data and event handlers.