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

JSX Children

Learn how to place text, elements, expressions, and reusable components inside JSX parent elements.

1. What Are JSX Children?

JSX children are the content placed between the opening and closing tags of a JSX element. Children can be text, other JSX elements, JavaScript expressions, or components.

Example: <div>Hello React</div>

The text Hello React is the child of the div element.

BasicChildren.jsx JSX
function App() {
    return (
        <div>
            <h2>Welcome to CIIT Training Institute</h2>
            <p>Learn React with practical examples.</p>
        </div>
    );
}

export default App;

2. JSX Children Structure

The parent element contains child elements. Those children can also contain their own children.

Parent Element <div>
Child 1 <h2> Heading text
Child 2 <p> Paragraph text
Parent → Children → Text content
ChildrenStructure.jsx JSX
function App() {
    return (
        <div>
            <h2>React Tutorial</h2>
            <p>Understanding JSX children.</p>
        </div>
    );
}

export default App;

3. Text as Children

Plain text can be placed directly between the opening and closing tags of an element.

TextChildren.jsx JSX
function App() {
    return (
        <div>
            <h2>Our Courses</h2>
            <p>Java Full Stack</p>
            <p>.NET Full Stack</p>
            <p>Python Full Stack</p>
        </div>
    );
}

export default App;

Expected Browser Output

Illustrative Browser Output

Our Courses

Java Full Stack

.NET Full Stack

Python Full Stack

4. JSX Elements as Children

A parent element can contain multiple nested JSX elements. This structure helps organize a page into meaningful sections.

NestedChildren.jsx JSX
function App() {
    return (
        <div className="course-card">
            <h2>React Full Stack</h2>
            <p>Learn component-based development.</p>

            <ul>
                <li>JSX</li>
                <li>Components</li>
                <li>Props</li>
            </ul>
        </div>
    );
}

export default App;

5. JavaScript Expressions as Children

Curly braces allow variables and expressions to become children of JSX elements.

ExpressionChildren.jsx JSX
function App() {
    const studentName = "Rahul";
    const completedLessons = 8;
    const totalLessons = 12;

    return (
        <div>
            <h2>Student Progress</h2>
            <p>Student: {studentName}</p>
            <p>
                Lessons completed:
                {completedLessons} / {totalLessons}
            </p>
            <p>
                Remaining lessons: {totalLessons - completedLessons}
            </p>
        </div>
    );
}

export default App;

Expected Browser Output

Illustrative Browser Output

Student Progress

Student: Rahul

Lessons completed: 8 / 12

Remaining lessons: 4

6. Components as Children

One React component can be placed inside another component. This helps you build reusable and well-organized user interfaces.

ComponentChildren.jsx JSX
function CourseDetails() {
    return (
        <div>
            <h3>React Full Stack</h3>
            <p>Learn React step by step.</p>
        </div>
    );
}

function App() {
    return (
        <main>
            <h2>Available Training</h2>
            <CourseDetails />
        </main>
    );
}

export default App;
Key point: CourseDetails is rendered inside the App component. Its returned JSX becomes part of the overall user interface.

7. Passing Children to a Component

When content is placed between a component's opening and closing tags, React makes that content available through the special children prop.

PassingChildren.jsx JSX
function InfoCard({ children }) {
    return (
        <div className="info-card">
            {children}
        </div>
    );
}

function App() {
    return (
        <InfoCard>
            <h2>Welcome Student</h2>
            <p>Start learning React today.</p>
        </InfoCard>
    );
}

export default App;
Remember: children is a prop, not a special HTML tag. It represents the content passed between the component tags.

8. Conditional Children

A condition can determine whether content appears inside a parent element.

ConditionalChildren.jsx JSX
function App() {
    const hasCompletedCourse = true;

    return (
        <div>
            <h2>Course Status</h2>

            {hasCompletedCourse && (
                <p>Congratulations! Course completed.</p>
            )}
        </div>
    );
}

export default App;

When hasCompletedCourse is true, the congratulatory message appears. When it is false, the message is omitted.

Important: Be careful when using && with numbers. For example, {0 && "Message"} renders 0. Use a Boolean condition when appropriate.

9. Common Mistakes

1. Forgetting a closing tag

Incorrect:

<p>Learn React

Correct:

<p>Learn React</p>

2. Returning multiple sibling elements

Wrap sibling elements inside one parent element or a React Fragment.

return (
    <>
        <h2>React</h2>
        <p>JSX Children</p>
    </>
);

3. Forgetting to render children

If a component receives children but never uses {children} in its returned JSX, that content will not appear.

10. Practice Questions

  1. Create a parent element containing a heading and three paragraphs.
  2. Display student information using JavaScript expressions.
  3. Create a reusable component that displays its children.
  4. Pass a heading and paragraph to an InfoCard component.
  5. Render a message only when a Boolean condition is true.

11. Summary

  • JSX children are content inside an element's tags.
  • Children can be text, nested elements, expressions, or components.
  • Curly braces embed JavaScript expressions.
  • Components can receive nested content through the children prop.
  • Conditional rendering can show or omit children.
  • Use valid JSX syntax and close elements correctly.