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

React Developer Tools and Profiler

Learn how to inspect React components, understand component renders, identify performance bottlenecks, and optimize React applications using React Developer Tools and Profiler.

1. Introduction to React Developer Tools

React Developer Tools is a browser extension that helps developers inspect and debug React applications. It provides information about the component tree, props, state, and component rendering behavior.

When an application becomes large, it can be difficult to determine why a component is rendering repeatedly or which part of the application is consuming more rendering time. React Developer Tools helps developers investigate these issues.

Key concept: First identify the actual performance problem. Then optimize the components or calculations responsible for it instead of optimizing every component unnecessarily.

2. What Can React Developer Tools Do?

Components

Inspect the component hierarchy, props, state, and context values of a React application.

Profiler

Record rendering activity and investigate which components rendered during an interaction.

Render Analysis

Investigate repeated renders and determine whether updates are necessary.

Debugging

Understand component relationships and inspect the values used by components.

3. Installing React Developer Tools

React Developer Tools is available as an extension for supported browsers. After installing it, open a React application and launch the browser's Developer Tools.

  1. Open the browser extension store.
  2. Search for React Developer Tools published by Meta.
  3. Install the extension.
  4. Open your React application in the browser.
  5. Open Developer Tools using F12 or the browser menu.
  6. Look for the Components and Profiler panels.
The React-specific panels appear when the extension detects a compatible React application. The exact panel layout may differ between browser and extension versions.

4. Understanding the Components Panel

The Components panel displays the React component tree. You can select a component and inspect its props, state, and other available debugging information.

StudentDashboard.jsx
import { useState } from 'react';

function StudentDetails({ name, course }) {
    return (
        <div>
            <h3>Student Details</h3>
            <p>Name: {name}</p>
            <p>Course: {course}</p>
        </div>
    );
}

export default function StudentDashboard() {
    const [count, setCount] = useState(0);

    return (
        <div>
            <h2>CIIT Training Institute</h2>
            <p>Dashboard Count: {count}</p>

            <button onClick={() => setCount(count + 1)}>
                Increase Count
            </button>

            <StudentDetails
                name="Samadhan"
                course="React"
            />
        </div>
    );
}

What can you inspect?

  • Select StudentDashboard to inspect its count state.
  • Select StudentDetails to inspect the name and course props.
  • Click Increase Count and observe the updated state.
  • Investigate which components render after the state update.

5. Introduction to React Profiler

The Profiler records React rendering activity so you can investigate the cost of updates. It helps you understand which components rendered during a recording and how much time React spent rendering them.

A profiling session can help answer questions such as:

  • Which components rendered after a button click?
  • Did a component render even though its visible data did not change?
  • Which components took longer to render?
  • Did a performance optimization reduce rendering work?
Important: A component render is not automatically a performance problem. Focus on expensive or unnecessary rendering work and measure the effect of any optimization.

6. Creating a Performance Example

The following example contains a counter and a student details component. You can use the Profiler to record what happens when the counter changes.

ProfilerExample.jsx
import { useState } from 'react';

function StudentCard({ name }) {
    console.log('StudentCard rendered');

    return (
        <div>
            <h3>Student: {name}</h3>
        </div>
    );
}

export default function ProfilerExample() {
    const [count, setCount] = useState(0);

    return (
        <div>
            <h2>Render Investigation</h2>

            <p>Count: {count}</p>

            <button onClick={() => setCount(count + 1)}>
                Increase Count
            </button>

            <StudentCard name="Samiksha" />
        </div>
    );
}

Each counter update causes the parent to render again. Because StudentCard is not memoized, it will normally render again when its parent renders. Use this example to establish a baseline before applying an optimization.

7. Profiling a React Application

  1. Run your React application in the browser.
  2. Open Developer Tools and select the Profiler panel.
  3. Start recording a profiling session.
  4. Perform a specific interaction, such as clicking Increase Count.
  5. Stop recording and inspect the recorded commits.
  6. Select a commit to examine the components that rendered.
  7. Review the available timing and component details.
  8. Repeat the same interaction after making an optimization.
Best approach: Compare the same interaction before and after optimization. Keep other conditions as similar as possible so the comparison is useful.

8. Optimizing a Component with React.memo

React.memo can skip a component render when its props remain unchanged according to React's default prop comparison. This can help when a parent renders frequently but a child does not need to update.

OptimizedProfilerExample.jsx
import { useState, memo } from 'react';

const StudentCard = memo(function StudentCard({ name }) {
    console.log('StudentCard rendered');

    return (
        <div>
            <h3>Student: {name}</h3>
        </div>
    );
});

export default function OptimizedProfilerExample() {
    const [count, setCount] = useState(0);

    return (
        <div>
            <h2>Optimized Render Investigation</h2>

            <p>Count: {count}</p>

            <button onClick={() => setCount(count + 1)}>
                Increase Count
            </button>

            <StudentCard name="Samiksha" />
        </div>
    );
}

Now repeat the profiling steps. Since the name prop remains unchanged, StudentCard can skip rendering when the parent counter changes, provided no other relevant update requires it to render.

Compare the two recordings to determine whether this optimization reduces work in your application. The result depends on the component, workload, and development environment.

9. Understanding Common Profiling Terms

Term Meaning
Render React calculates what a component should display.
Commit React applies the relevant changes to the rendered tree.
Component Tree The hierarchy of components in the React application.
Props Values passed from a parent component to a child component.
State Component-managed data that can trigger an update.
Memoization Reusing a cached value, result, or function reference when appropriate.

10. Common Mistakes During Profiling

  • Optimizing without measuring: Identify a real bottleneck before changing code.
  • Assuming every render is bad: Rendering is a normal part of React's update process.
  • Comparing different workloads: Use the same interaction before and after an optimization.
  • Ignoring development behavior: Development tools and Strict Mode can affect observations.
  • Adding memoization everywhere: Memoization has costs and should be used where it provides value.
  • Ignoring the user experience: A small timing difference may not be meaningful to the user.

11. Best Practices

  • Use the Components panel to inspect component props and state.
  • Use the Profiler to investigate actual rendering behavior.
  • Record a baseline before making performance changes.
  • Apply one optimization at a time and measure the result.
  • Prefer clear, maintainable code over unnecessary memoization.
  • Test performance under realistic application workloads.

12. Practice Tasks

  1. Create a dashboard with a counter and a student details component.
  2. Inspect both components in the React Developer Tools Components panel.
  3. Record a profiling session while repeatedly updating the counter.
  4. Wrap the student details component with React.memo.
  5. Record the same interaction again and compare the results.
  6. Explain which component rendered, why it rendered, and whether the optimization helped.

Summary

React Developer Tools helps developers inspect component trees, props, and state, while the Profiler helps investigate rendering activity and performance costs. By recording a baseline, identifying unnecessary work, applying focused optimizations such as React.memo, and profiling again, developers can make informed performance decisions and keep React applications responsive and maintainable.