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

Children Props

Learn how to pass content between the opening and closing tags of a React component and display it using the special children prop.

01 What Is the Children Prop?

The special children prop contains the content placed between a component's opening and closing tags. That content can be text, JSX elements or other components.

Children Prop Flow
Parent Component App renders a StudentCard
↓
<StudentCard> Samadhan is learning React JS </StudentCard>
↓ children
Child Component Displays the received content
The name children is special in React: it represents nested content passed between a component's tags.
Expected Browser Output

Samadhan is learning React JS

02 Passing Simple Text as Children

Text placed between the component tags becomes the children value.

App.jsx
function App() {
    return (
        <Message>
            Welcome to CIIT Training Institute!
        </Message>
    );
}

function Message({ children }) {
    return <p>{children}</p>;
}

export default App;
Expected Browser Output

Welcome to CIIT Training Institute!

03 Passing JSX Elements as Children

Children can contain JSX elements, not just plain text. The receiving component can render those elements inside its layout.

App.jsx
function App() {
    return (
        <StudentCard>
            <h2>Samiksha</h2>
            <p>Course: React JS</p>
        </StudentCard>
    );
}

function StudentCard({ children }) {
    return (
        <div>
            {children}
        </div>
    );
}

export default App;
JSX as Children
StudentCard Receives nested JSX
↓
h2 Samiksha
p Course: React JS
Expected Browser Output

Samiksha

Course: React JS

04 Using Children Inside a Card

A reusable card component can provide the common border and spacing while allowing the parent to decide what content appears.

App.jsx
function App() {
    return (
        <Card>
            <h3>React JS</h3>
            <p>Learn components and props.</p>
        </Card>
    );
}

function Card({ children }) {
    return (
        <div className="card">
            {children}
        </div>
    );
}

export default App;
In a real React project, define the .card CSS class in your stylesheet to style the container.
Expected Browser Output

React JS

Learn components and props.

05 Passing Multiple Elements as Children

Multiple JSX elements can be passed inside one component. React treats the nested content as the component's children.

App.jsx
function App() {
    return (
        <Panel>
            <h2>Student Details</h2>
            <p>Name: Pradnya</p>
            <p>Course: Full Stack Development</p>
        </Panel>
    );
}

function Panel({ children }) {
    return (
        <section>
            {children}
        </section>
    );
}

export default App;
Expected Browser Output

Student Details

Name: Pradnya

Course: Full Stack Development

06 Children Along with Other Props

A component can receive regular props such as title and children together. Regular props configure the component, while children supply the nested content.

App.jsx
function App() {
    return (
        <CourseCard title="React JS">
            <p>Duration: 3 Months</p>
            <p>Includes hands-on practice.</p>
        </CourseCard>
    );
}

function CourseCard({ title, children }) {
    return (
        <div>
            <h2>{title}</h2>
            {children}
        </div>
    );
}

export default App;
Regular Props + Children
CourseCard title="React JS"
↓
title React JS
children Duration and details
Expected Browser Output

React JS

Duration: 3 Months

Includes hands-on practice.

07 Reusable Layout with Children

Children props are useful for reusable layouts. The layout component controls the common structure, while the parent supplies the page-specific content.

App.jsx
function App() {
    return (
        <Layout>
            <h2>React Components</h2>
            <p>Explore reusable UI components.</p>
        </Layout>
    );
}

function Layout({ children }) {
    return (
        <main>
            <header>CIIT Training Institute</header>
            <section>{children}</section>
            <footer>Learn by building projects</footer>
        </main>
    );
}

export default App;
Expected Browser Output

CIIT Training Institute

React Components

Explore reusable UI components.


Learn by building projects

08 Conditional Rendering of Children

A component can render its children only when a condition is satisfied. This is useful for optional descriptions or content.

App.jsx
function App() {
    return (
        <InfoBox showDetails={true}>
            <p>Students can practice React examples.</p>
        </InfoBox>
    );
}

function InfoBox({ showDetails, children }) {
    return (
        <div>
            <h3>Course Information</h3>
            {showDetails ? children : <p>Details hidden.</p>}
        </div>
    );
}

export default App;
Expected Browser Output

Course Information

Students can practice React examples.

09 Handling Optional Children

A component may be rendered without nested content. You can check whether children were provided and show fallback content.

App.jsx
function App() {
    return (
        <div>
            <Message>Welcome Samadhan!</Message>
            <Message />
        </div>
    );
}

function Message({ children }) {
    return (
        <div>
            {children ?? <p>No message available.</p>}
        </div>
    );
}

export default App;
Expected Browser Output

Welcome Samadhan!

No message available.

10 Complete Children Props Example

This example combines regular props and children to build a reusable student profile card.

App.jsx
function App() {
    return (
        <StudentCard name="Pradnya" course="React JS">
            <p>Skills: HTML, CSS and JavaScript</p>
            <p>Institute: CIIT Training Institute</p>
        </StudentCard>
    );
}

function StudentCard({ name, course, children }) {
    return (
        <article>
            <h2>{name}</h2>
            <p>Course: {course}</p>
            {children}
        </article>
    );
}

export default App;
Complete Component Structure
App Passes name and course
↓
StudentCard name="Pradnya" course="React JS"
↓ children
Skills HTML, CSS, JavaScript
Institute CIIT Training Institute
Expected Browser Output

Pradnya

Course: React JS

Skills: HTML, CSS and JavaScript

Institute: CIIT Training Institute

Summary

The children prop allows a React component to receive and display content placed between its opening and closing tags. This content may be plain text, JSX elements or other components. Children can be combined with regular props to build reusable cards, layouts and conditional content. Using children effectively helps create flexible, maintainable React interfaces at CIIT Training Institute.