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

Component Composition in React

Learn how to combine small, reusable components to build complete user interfaces at CIIT Training Institute.

Beginner Friendly Practical Examples Expected Output Included

01 Learning Objectives

After completing this lesson, you will be able to:

01
Understand Composition

Learn how small components work together.

02
Build Parent Components

Organize child components inside a parent.

03
Reuse UI Elements

Avoid duplicating the same interface code.

04
Use Props and Children

Pass data and nested content between components.

02 What Is Component Composition?

Component composition means building a larger interface by combining smaller React components. Each component handles a particular part of the UI.

Remember: A parent component can render multiple child components. Together, they form the complete interface.
App.jsx JSX
function Header() {
    return <h2>CIIT Training Institute</h2>;
}

function CourseDetails() {
    return <p>Learn React JS with practical examples.</p>;
}

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

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

export default App;
Expected Browser Output

CIIT Training Institute

Learn React JS with practical examples.

Learn. Practice. Build Projects.

03 Component Composition Diagram

In this example, the main App component combines the Header, CourseList and Footer components.

CIIT TRAINING INSTITUTE — COMPONENT TREE
PARENT App() Main application component
CHILD 1 Header() Branding and heading
CHILD 2 CourseList() Available courses
CHILD 3 Footer() Closing message
App combines three independent components into one complete page.
App.jsx JSX
function Header() {
    return <h2>CIIT Training Institute</h2>;
}

function CourseList() {
    return (
        <ul>
            <li>React JS</li>
            <li>.NET Full Stack</li>
            <li>Python</li>
        </ul>
    );
}

function Footer() {
    return <footer>Start Learning Today!</footer>;
}

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

export default App;
Expected Browser Output

CIIT Training Institute

  • React JS
  • .NET Full Stack
  • Python
Start Learning Today!

04 Composition with Props

Props allow a parent component to provide data to child components. Here, the same course component displays different course information.

CourseCard.jsx JSX
function CourseCard({ title, duration }) {
    return (
        <div>
            <h3>{title}</h3>
            <p>Duration: {duration}</p>
        </div>
    );
}

export default CourseCard;
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

05 Composition with the children Prop

The special children prop lets a component display content nested between its opening and closing tags.

InfoPanel.jsx JSX
function InfoPanel({ title, children }) {
    return (
        <section>
            <h3>{title}</h3>
            <div>{children}</div>
        </section>
    );
}

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

function App() {
    return (
        <div>
            <InfoPanel title="Welcome">
                <p>Welcome to CIIT Training Institute.</p>
                <p>Learn through practical projects.</p>
            </InfoPanel>
        </div>
    );
}

export default App;
Expected Browser Output

Welcome

Welcome to CIIT Training Institute.

Learn through practical projects.

06 Nested Component Composition

A component can contain another component, which can itself contain more components. This creates a hierarchy of UI elements.

App
↓
CourseSection
↓
CourseTitle
CourseDetails
App.jsx JSX
function CourseTitle() {
    return <h2>React JS Training</h2>;
}

function CourseDetails() {
    return (
        <p>
            Learn components and props at CIIT Training Institute.
        </p>
    );
}

function CourseSection() {
    return (
        <section>
            <CourseTitle />
            <CourseDetails />
        </section>
    );
}

function App() {
    return <CourseSection />;
}

export default App;
Expected Browser Output

React JS Training

Learn components and props at CIIT Training Institute.

07 Best Practices

✓

Keep each component focused on a clear responsibility.

✓

Use props to customize reusable components.

✓

Use children when a component should wrap nested content.

✓

Split large interfaces into smaller, understandable components.

✓

Keep component names descriptive and start them with uppercase letters.

08 Practice Questions

  1. Create an App component containing Header, MainContent and Footer.
  2. Create a reusable CourseCard component using title and duration props.
  3. Display React JS, .NET Full Stack and Python using one component.
  4. Create an InfoPanel component that accepts nested content through children.
  5. Draw a component tree for a student dashboard.
  6. Build a course page by combining at least four components.

Summary

Component Composition is the practice of combining smaller React components to build a larger interface. Parent components can render child components, props provide data, and the special children prop allows nested content. By using composition, developers can create reusable, organized and maintainable applications. At CIIT Training Institute, practise composition with course cards, student profiles and page layouts.