Free ATS Friendly Resume Builder Online

Create Your Resume

Resume Builder

Resume Maker

Resume Templates

Resume PDF Download

Create Your Resume is a free online resume builder that helps job seekers create professional, ATS friendly resumes in minutes. Easily build, customize, and download modern resume templates in PDF format.

Our resume maker is designed for freshers and experienced professionals looking to create job-ready resumes. Choose from multiple resume templates, customize sections, and generate ATS optimized resumes online for free.

Create resumes for IT jobs, software developers, freshers, experienced professionals, managers, and students. This free resume builder supports CV creation, resume PDF download, and online resume editing without signup.

Back to React Js
Lesson 49 of 59

What Are Performance Optimization Principles in React? How React.memo, useCallback, useMemo, Image Lazy Loading, and Re-render Prevention Work

Performance optimization in React focuses on minimizing unnecessary work while keeping user interfaces responsive, scalable, and predictable. As React applications grow, inefficient re-renders, repeated computations, unoptimized event handlers, and heavy assets like images can significantly degrade performance. React provides built-in tools such as React.memo, useCallback, and useMemo to control rendering behavior and computation cost, while browser-level techniques like image lazy loading reduce initial load time and bandwidth usage. This guide explains the fundamental principles behind React performance optimization, how React decides when to re-render, how memoization works internally, when to use or avoid React.memo, useCallback, and useMemo, how to prevent unnecessary re-renders, and how image lazy loading improves Core Web Vitals in real-world production applications.

Why Performance Optimization Matters in React

React is fast by default, but it is not magically performant. Poor component design, unnecessary re-renders, and heavy assets can quickly degrade user experience.

Performance problems usually appear when:

  • Applications grow large
  • State updates happen frequently
  • Lists and dashboards render complex UIs
  • Images and media are unoptimized

Production-grade applications such as data-heavy React platforms require deliberate performance strategies from day one.

Core Performance Optimization Principles in React

1. Minimize Re-renders

Every re-render has a cost. While React optimizes DOM updates, rendering itself can still be expensive.

2. Avoid Unnecessary Computation

Expensive calculations during render slow down the UI and block the main thread.

3. Split Work by Priority

User interactions should always be more important than background updates.

4. Load Only What Is Needed

Large bundles and images delay initial render and hurt Core Web Vitals.

Understanding Why Components Re-render

A React component re-renders when:

  • Its state changes
  • Its props change
  • Its parent re-renders

Even if props “look the same”, new object or function references will trigger re-renders.

React.memo

What Is React.memo?

React.memo is a higher-order component that memoizes a functional component.

If props do not change, React skips re-rendering the component.

Basic Example


const Button = React.memo(function Button({ label }) {
  console.log("Rendered");
  return <button>{label}</button>;
});

When React.memo Helps

  • Pure presentational components
  • Components with expensive rendering
  • Frequently re-rendered parent components

When React.memo Does NOT Help

  • Components with changing props
  • Components with inline objects/functions
  • Very small components

useCallback Hook

What Is useCallback?

useCallback memoizes a function reference between renders.

Without it, functions are recreated on every render.

Problem Example (Without useCallback)


function Parent() {
  const handleClick = () => {
    console.log("Clicked");
  };

  return <Child onClick={handleClick} />;
}

This causes Child to re-render unnecessarily.

Optimized Example


const handleClick = useCallback(() => {
  console.log("Clicked");
}, []);

This pattern is critical in interactive flows such as dynamic form and preview experiences.

useMemo Hook

What Is useMemo?

useMemo memoizes the result of a computation.

It prevents expensive recalculations during render.

Example Without useMemo


const filtered = items.filter(item => item.active);

Optimized Example


const filtered = useMemo(() => {
  return items.filter(item => item.active);
}, [items]);

When to Use useMemo

  • Expensive calculations
  • Large lists or data sets
  • Derived data used multiple times

When NOT to Use useMemo

  • Cheap calculations
  • Premature optimization

React.memo vs useCallback vs useMemo (Comparison)

Tool What It Memoizes Main Use
React.memoComponent renderPrevent child re-renders
useCallbackFunction referenceStable callbacks
useMemoComputed valueExpensive calculations

Preventing Unnecessary Re-renders (Strategies)

  • Lift state only when needed
  • Avoid inline object literals
  • Split large components
  • Use keys correctly in lists

Over-rendering issues are frequently discussed in React performance deep-dive articles.

Image Lazy Loading

Why Images Hurt Performance

  • Large file sizes
  • Block initial render
  • Increase bandwidth usage

Native Lazy Loading


<img src="photo.jpg" loading="lazy" alt="Profile" />

Benefits

  • Faster initial page load
  • Lower memory usage
  • Better Core Web Vitals

React Lazy Loading for Images

Combine lazy loading with route-based rendering to load images only when needed.

Real-World Performance Scenario

Consider a dashboard with:

  • Search filters
  • Large data tables
  • Profile images

Without optimization:

  • Every keystroke re-renders everything
  • UI becomes sluggish

With optimization:

  • Only affected components update
  • Images load on demand
  • UI stays responsive

Performance patterns like these are tested via scenario-based evaluations.

Common Performance Mistakes

  • Overusing memoization
  • Ignoring dependency arrays
  • Optimizing without profiling
  • Memoizing everything blindly

Best Practices & Special Notes

  • Measure before optimizing
  • Optimize hot paths only
  • Prefer clarity over premature optimization
  • Combine memoization with good architecture

Final Takeaway

Performance optimization in React is about reducing unnecessary work, not eliminating all re-renders. Tools like React.memo, useCallback, and useMemo are powerful when used correctly but harmful when misused. Combined with image lazy loading and sound architectural principles, they enable React applications to remain fast, scalable, and responsive even under heavy workloads.