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

Rendering JSX Elements

Learn how JSX elements are created, returned from React components, rendered conditionally, and updated using dynamic JavaScript values.

1. What Is Rendering?

Rendering means displaying the user interface produced by a React component. A component returns JSX that describes what should appear on the screen.

Remember: A React component describes the UI. React uses that description to update the browser when necessary.
RenderingExample.jsx JSX
function App() {
    return (
        <div>
            <h1>Welcome to CIIT Training Institute</h1>
            <p>Learn React step by step.</p>
        </div>
    );
}

export default App;

2. Rendering Flow Diagram

Understand the basic flow from a component to the displayed user interface.

01 React Component App()
↓
02 Returned JSX Elements and content
↓
03 React Rendering Creates or updates the UI
↓
04 Browser UI Visible page content

Conceptual flow: a component returns JSX, and React renders the corresponding user interface.

3. Rendering Multiple Elements

A component can return multiple JSX elements when they are wrapped inside one parent element or a React Fragment.

MultipleElements.jsx JSX
function App() {
    return (
        <section>
            <h2>Our Training Programs</h2>
            <p>Java Full Stack</p>
            <p>.NET Full Stack</p>
            <p>Python Full Stack</p>
        </section>
    );
}

export default App;

Expected Browser Output

Illustrative Browser Output

Our Training Programs

Java Full Stack

.NET Full Stack

Python Full Stack

4. Rendering Dynamic Values

JavaScript variables and expressions can be placed inside JSX curly braces to display dynamic information.

DynamicRendering.jsx JSX
function App() {
    const studentName = "Priya";
    const courseName = "React JS";
    const totalLessons = 25;

    return (
        <div>
            <h2>Student Dashboard</h2>
            <p>Student: {studentName}</p>
            <p>Course: {courseName}</p>
            <p>Total Lessons: {totalLessons}</p>
        </div>
    );
}

export default App;

Expected Browser Output

Illustrative Browser Output

Student Dashboard

Student: Priya

Course: React JS

Total Lessons: 25

5. Conditional Rendering

Conditional rendering means displaying different content based on a condition. A ternary expression can choose between two values.

ConditionalRendering.jsx JSX
function App() {
    const isLoggedIn = true;

    return (
        <div>
            <h2>Student Portal</h2>

            <p>
                {isLoggedIn
                    ? "Welcome back, Student!"
                    : "Please log in to continue."}
            </p>
        </div>
    );
}

export default App;
Key point: When isLoggedIn is true, the welcome message is displayed. When it is false, the login message appears.

6. Rendering Lists Using map()

The JavaScript map() method transforms array items into JSX elements. React uses the resulting elements to display a list.

ListRendering.jsx JSX
function App() {
    const courses = [
        "Java Full Stack",
        ".NET Full Stack",
        "Python Full Stack"
    ];

    return (
        <div>
            <h2>Available Courses</h2>

            <ul>
                {courses.map((course) => (
                    <li key={course}>{course}</li>
                ))}
            </ul>
        </div>
    );
}

export default App;

Expected Browser Output

Illustrative Browser Output

Available Courses

  • Java Full Stack
  • .NET Full Stack
  • Python Full Stack
Why use key? Each list element needs a stable, unique key among its siblings so React can identify items when the list changes.

7. Rendering Empty Values

React does not render null, undefined, or Boolean values as ordinary text when they are used as children.

EmptyValues.jsx JSX
function App() {
    const message = null;
    const isVisible = false;

    return (
        <div>
            <p>Start Learning</p>
            {message}
            {isVisible}
            <p>Continue Learning</p>
        </div>
    );
}

export default App;

Expected Browser Output

Illustrative Browser Output

Start Learning

Continue Learning

8. Common Mistakes

1. Returning multiple sibling elements directly

Incorrect:

return (
    <h2>React Tutorial</h2>
    <p>Learn JSX</p>
);

Correct:

return (
    <div>
        <h2>React Tutorial</h2>
        <p>Learn JSX</p>
    </div>
);

2. Forgetting the key property in lists

Avoid:

courses.map(course => <li>{course}</li>)

Use:

courses.map(course => <li key={course}>{course}</li>)

3. Expecting false to appear as text

{false} does not display the word "false" as a text node. Convert it to a string if you want to display that word.

9. Practice Questions

  1. Create a component that renders a heading and three paragraphs.
  2. Display a student's name, course, and score using variables.
  3. Show a different message depending on a Boolean value.
  4. Render a list of five course names using map() and stable keys.
  5. Display a message only when a condition is true.

10. Summary

  • Components return JSX to describe the user interface.
  • Multiple sibling JSX elements need a common parent or Fragment.
  • Curly braces allow JavaScript expressions inside JSX.
  • Conditional expressions can display different content.
  • The map() method can render arrays as lists.
  • List items should have stable, unique keys among siblings.