<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Muneeb Ansari | BiteGlitz</title>
    <description>The latest articles on DEV Community by Muneeb Ansari | BiteGlitz (@biteglitz).</description>
    <link>https://dev.to/biteglitz</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4058331%2F00f40469-6e9b-41fb-9c7a-7b5cbb050cc9.png</url>
      <title>DEV Community: Muneeb Ansari | BiteGlitz</title>
      <link>https://dev.to/biteglitz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/biteglitz"/>
    <language>en</language>
    <item>
      <title>How to Find and Fix Slow Components</title>
      <dc:creator>Muneeb Ansari | BiteGlitz</dc:creator>
      <pubDate>Sat, 08 Aug 2026 22:34:54 +0000</pubDate>
      <link>https://dev.to/biteglitz/how-to-find-and-fix-slow-components-4hm7</link>
      <guid>https://dev.to/biteglitz/how-to-find-and-fix-slow-components-4hm7</guid>
      <description>&lt;p&gt;A practical guide to measuring React rendering performance, identifying slow components, understanding render causes, and fixing performance problems without premature optimization.&lt;/p&gt;

&lt;p&gt;Introduction&lt;/p&gt;

&lt;p&gt;A React application can feel slow for many different reasons.&lt;/p&gt;

&lt;p&gt;Maybe clicking a button causes a noticeable delay. Maybe typing into a search field feels laggy. Maybe opening a dashboard takes too long. Or perhaps a component takes hundreds of milliseconds to render even though the UI doesn't look particularly complicated.&lt;/p&gt;

&lt;p&gt;The difficult part isn't knowing that something is slow.&lt;/p&gt;

&lt;p&gt;The difficult part is finding what is actually slow.&lt;/p&gt;

&lt;p&gt;This is where the React Profiler becomes useful.&lt;/p&gt;

&lt;p&gt;Instead of guessing which component is responsible for a performance problem, you can record an interaction and inspect:&lt;/p&gt;

&lt;p&gt;Which components rendered&lt;br&gt;
How long rendering took&lt;br&gt;
Which components rendered repeatedly&lt;br&gt;
Which components were affected by an update&lt;br&gt;
How expensive individual renders were&lt;br&gt;
Whether an optimization actually improved performance&lt;/p&gt;

&lt;p&gt;This article walks through a practical workflow for finding slow React components and fixing them.&lt;/p&gt;

&lt;p&gt;It is intended for developers who already understand basic React concepts such as components, props, state, and hooks.&lt;/p&gt;

&lt;p&gt;Table of Contents&lt;br&gt;
What Is the React Profiler?&lt;br&gt;
Rendering vs DOM Updates&lt;br&gt;
Why Measuring Performance Matters&lt;br&gt;
Setting Up React DevTools&lt;br&gt;
Recording a Performance Profile&lt;br&gt;
Understanding the Profiler Interface&lt;br&gt;
Finding Slow Components&lt;br&gt;
Understanding Render Causes&lt;br&gt;
Example: A Slow Component&lt;br&gt;
Fixing Expensive Calculations&lt;br&gt;
Fixing Unnecessary Child Renders&lt;br&gt;
Optimizing Large Lists&lt;br&gt;
Using the Browser Performance Panel&lt;br&gt;
Measuring Before and After&lt;br&gt;
Best Practices&lt;br&gt;
Common Mistakes&lt;br&gt;
Performance Tips&lt;br&gt;
Security Considerations&lt;br&gt;
Accessibility Considerations&lt;br&gt;
SEO Considerations&lt;br&gt;
Real Project Example&lt;br&gt;
Conclusion&lt;br&gt;
Discussion&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What Is the React Profiler?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The React Profiler is a performance analysis tool available through React DevTools.&lt;/p&gt;

&lt;p&gt;It helps developers understand how React components behave during rendering.&lt;/p&gt;

&lt;p&gt;A simplified workflow looks like this:&lt;/p&gt;

&lt;p&gt;User interaction&lt;br&gt;
      ↓&lt;br&gt;
React update&lt;br&gt;
      ↓&lt;br&gt;
Components render&lt;br&gt;
      ↓&lt;br&gt;
Profiler records activity&lt;br&gt;
      ↓&lt;br&gt;
Developer analyzes expensive work&lt;br&gt;
      ↓&lt;br&gt;
Targeted optimization&lt;br&gt;
      ↓&lt;br&gt;
Profile again&lt;/p&gt;

&lt;p&gt;The important part is the last step.&lt;/p&gt;

&lt;p&gt;Profiling should be an iterative process.&lt;/p&gt;

&lt;p&gt;Don't assume that changing code made your application faster. Measure it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Rendering vs DOM Updates&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One of the most important concepts to understand is that a React render doesn't necessarily mean the browser DOM was changed.&lt;/p&gt;

&lt;p&gt;Consider:&lt;/p&gt;

&lt;p&gt;function UserProfile({ user }) {&lt;br&gt;
  return (&lt;br&gt;
    &lt;/p&gt;
&lt;br&gt;
      &lt;h2&gt;{user.name}&lt;/h2&gt;
&lt;br&gt;
      &lt;p&gt;{user.email}&lt;/p&gt;
&lt;br&gt;
    &lt;br&gt;
  );&lt;br&gt;
}

&lt;p&gt;When React renders this component, React calculates what the UI should look like.&lt;/p&gt;

&lt;p&gt;It then compares the result with the previous render.&lt;/p&gt;

&lt;p&gt;If nothing changed, React may not need to update the actual DOM.&lt;/p&gt;

&lt;p&gt;So when profiling React, don't automatically assume:&lt;/p&gt;

&lt;p&gt;"This component rendered, therefore the DOM was updated."&lt;/p&gt;

&lt;p&gt;Rendering is one stage of React's update process.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Why Measuring Performance Matters&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Imagine a dashboard contains:&lt;/p&gt;

&lt;p&gt;Dashboard&lt;br&gt;
├── Header&lt;br&gt;
├── Sidebar&lt;br&gt;
├── Search&lt;br&gt;
├── Statistics&lt;br&gt;
├── RevenueChart&lt;br&gt;
├── OrdersTable&lt;br&gt;
└── Notifications&lt;/p&gt;

&lt;p&gt;A developer notices that typing into the search box feels slow.&lt;/p&gt;

&lt;p&gt;One possible assumption is:&lt;/p&gt;

&lt;p&gt;"The search input must be slow."&lt;/p&gt;

&lt;p&gt;But the actual problem could be:&lt;/p&gt;

&lt;p&gt;Search input&lt;br&gt;
     ↓&lt;br&gt;
Dashboard state update&lt;br&gt;
     ↓&lt;br&gt;
RevenueChart renders&lt;br&gt;
     ↓&lt;br&gt;
OrdersTable renders&lt;br&gt;
     ↓&lt;br&gt;
Statistics renders&lt;br&gt;
     ↓&lt;br&gt;
Notifications renders&lt;/p&gt;

&lt;p&gt;The search input may be perfectly fine.&lt;/p&gt;

&lt;p&gt;The real problem could be that one of the unrelated components performs expensive work every time the search state changes.&lt;/p&gt;

&lt;p&gt;Without profiling, you're guessing.&lt;/p&gt;

&lt;p&gt;With profiling, you can investigate the actual rendering behavior.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Setting Up React DevTools&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;React DevTools is available as a browser extension and provides development tools for inspecting React applications.&lt;/p&gt;

&lt;p&gt;After installing it, open your React application and open the browser's developer tools.&lt;/p&gt;

&lt;p&gt;You should see React-specific panels such as:&lt;/p&gt;

&lt;p&gt;Components&lt;br&gt;
Profiler&lt;/p&gt;

&lt;p&gt;The exact interface can change between React DevTools versions, so focus on the concepts rather than memorizing a particular UI layout.&lt;/p&gt;

&lt;p&gt;Important: Profile your application in a realistic development environment and, when appropriate, validate important findings with a production build. Development behavior can include additional checks and instrumentation.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Recording a Performance Profile&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's use a simple application.&lt;/p&gt;

&lt;p&gt;import { useState } from "react";&lt;/p&gt;

&lt;p&gt;function App() {&lt;br&gt;
  const [count, setCount] = useState(0);&lt;/p&gt;

&lt;p&gt;return (&lt;br&gt;
    &lt;/p&gt;
&lt;br&gt;
       setCount((value) =&amp;gt; value + 1)}&amp;gt;&lt;br&gt;
        Count: {count}&lt;br&gt;
      
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;SlowComponent /&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;The component below intentionally performs expensive work:&lt;/p&gt;

&lt;p&gt;function SlowComponent() {&lt;br&gt;
  let total = 0;&lt;/p&gt;

&lt;p&gt;for (let i = 0; i &amp;lt; 50_000_000; i++) {&lt;br&gt;
    total += i;&lt;br&gt;
  }&lt;/p&gt;

&lt;p&gt;return &lt;/p&gt;
&lt;p&gt;Result: {total}&lt;/p&gt;;&lt;br&gt;
}

&lt;p&gt;Every time App renders, SlowComponent renders too.&lt;/p&gt;

&lt;p&gt;That means clicking the button can repeatedly execute the expensive loop.&lt;/p&gt;

&lt;p&gt;Profile it&lt;/p&gt;

&lt;p&gt;A practical workflow is:&lt;/p&gt;

&lt;p&gt;Open the application.&lt;br&gt;
Open React DevTools.&lt;br&gt;
Open the Profiler.&lt;br&gt;
Start recording.&lt;br&gt;
Perform the interaction that feels slow.&lt;br&gt;
Stop recording.&lt;br&gt;
Inspect the recorded commit.&lt;br&gt;
Look for expensive components.&lt;br&gt;
Change the code.&lt;br&gt;
Profile the same interaction again.&lt;/p&gt;

&lt;p&gt;The important principle is:&lt;/p&gt;

&lt;p&gt;Reproduce the same interaction before and after the optimization.&lt;/p&gt;

&lt;p&gt;That makes your comparison much more useful.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Understanding the Profiler Interface&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The Profiler provides several useful ways to inspect rendering activity.&lt;/p&gt;

&lt;p&gt;Depending on the React DevTools version, you'll encounter visualizations such as:&lt;/p&gt;

&lt;p&gt;Flamegraph&lt;br&gt;
Ranked view&lt;br&gt;
Commit information&lt;br&gt;
Component render timings&lt;/p&gt;

&lt;p&gt;The names and presentation may evolve, but the underlying questions remain the same.&lt;/p&gt;

&lt;p&gt;Flamegraph&lt;/p&gt;

&lt;p&gt;The flamegraph helps visualize the component tree and rendering work.&lt;/p&gt;

&lt;p&gt;You can use it to identify components that take a significant amount of time.&lt;/p&gt;

&lt;p&gt;Ranked View&lt;/p&gt;

&lt;p&gt;A ranked view is useful when you want to quickly find the components that consumed the most rendering time.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;OrdersTable       120 ms&lt;br&gt;
RevenueChart       82 ms&lt;br&gt;
Statistics         18 ms&lt;br&gt;
Header              2 ms&lt;br&gt;
Footer              1 ms&lt;/p&gt;

&lt;p&gt;This immediately gives you a better starting point.&lt;/p&gt;

&lt;p&gt;Instead of optimizing Header, investigate OrdersTable.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Finding Slow Components&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Suppose your profile shows:&lt;/p&gt;

&lt;p&gt;Dashboard       145 ms&lt;br&gt;
OrdersTable     118 ms&lt;br&gt;
SearchBar         3 ms&lt;br&gt;
Header            2 ms&lt;br&gt;
Footer            1 ms&lt;/p&gt;

&lt;p&gt;The first place to investigate is OrdersTable.&lt;/p&gt;

&lt;p&gt;But don't immediately add React.memo.&lt;/p&gt;

&lt;p&gt;First ask:&lt;/p&gt;

&lt;p&gt;Why is OrdersTable expensive?&lt;/p&gt;

&lt;p&gt;Potential causes include:&lt;/p&gt;

&lt;p&gt;Large calculations&lt;br&gt;
Sorting data during render&lt;br&gt;
Filtering thousands of records&lt;br&gt;
Rendering too many DOM nodes&lt;br&gt;
Complex child components&lt;br&gt;
Expensive formatting&lt;br&gt;
Unnecessary state updates&lt;br&gt;
Repeated API transformations&lt;/p&gt;

&lt;p&gt;Profiling tells you where the problem is.&lt;/p&gt;

&lt;p&gt;Your code inspection determines why it happens.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Understanding Render Causes&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Finding a slow component is only half of the job.&lt;/p&gt;

&lt;p&gt;You also need to understand why it rendered.&lt;/p&gt;

&lt;p&gt;Common reasons include:&lt;/p&gt;

&lt;p&gt;State changed&lt;br&gt;
const [count, setCount] = useState(0);&lt;/p&gt;

&lt;p&gt;Calling:&lt;/p&gt;

&lt;p&gt;setCount((value) =&amp;gt; value + 1);&lt;/p&gt;

&lt;p&gt;causes the component using that state to update.&lt;/p&gt;

&lt;p&gt;Props changed&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;If user changes, the child may need to render again.&lt;/p&gt;

&lt;p&gt;Parent rendered&lt;/p&gt;

&lt;p&gt;A child can render when its parent renders, even if the child doesn't have its own state update.&lt;/p&gt;

&lt;p&gt;Context changed&lt;/p&gt;

&lt;p&gt;Components consuming a changed context value may render again.&lt;/p&gt;

&lt;p&gt;Understanding the cause is important because different causes require different solutions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Example: A Slow Component&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Consider this component:&lt;/p&gt;

&lt;p&gt;function ProductList({ products, search }) {&lt;br&gt;
  const filteredProducts = products&lt;br&gt;
    .filter((product) =&amp;gt;&lt;br&gt;
      product.name.toLowerCase().includes(search.toLowerCase())&lt;br&gt;
    )&lt;br&gt;
    .sort((a, b) =&amp;gt; a.name.localeCompare(b.name));&lt;/p&gt;

&lt;p&gt;return (&lt;br&gt;
    &lt;/p&gt;
&lt;ul&gt;

      {filteredProducts.map((product) =&amp;gt; (
        &lt;li&gt;

          {product.name}
        &lt;/li&gt;

      ))}
    &lt;/ul&gt;
&lt;br&gt;
  );&lt;br&gt;
}

&lt;p&gt;For a list containing 50 items, this may be completely fine.&lt;/p&gt;

&lt;p&gt;For 50,000 items, the situation changes.&lt;/p&gt;

&lt;p&gt;Every render performs:&lt;/p&gt;

&lt;p&gt;Filtering&lt;br&gt;
Sorting&lt;br&gt;
Mapping&lt;br&gt;
Creating many React elements&lt;/p&gt;

&lt;p&gt;If the component renders frequently, the work can become expensive.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fixing Expensive Calculations&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One possible optimization is to memoize the derived data.&lt;/p&gt;

&lt;p&gt;import { useMemo } from "react";&lt;/p&gt;

&lt;p&gt;function ProductList({ products, search }) {&lt;br&gt;
  const filteredProducts = useMemo(() =&amp;gt; {&lt;br&gt;
    const query = search.toLowerCase();&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return products
  .filter((product) =&amp;gt;
    product.name.toLowerCase().includes(query)
  )
  .sort((a, b) =&amp;gt; a.name.localeCompare(b.name));
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;}, [products, search]);&lt;/p&gt;

&lt;p&gt;return (&lt;br&gt;
    &lt;/p&gt;
&lt;ul&gt;

      {filteredProducts.map((product) =&amp;gt; (
        &lt;li&gt;

          {product.name}
        &lt;/li&gt;

      ))}
    &lt;/ul&gt;
&lt;br&gt;
  );&lt;br&gt;
}

&lt;p&gt;Now React can reuse the calculated value when the dependencies haven't changed.&lt;/p&gt;

&lt;p&gt;However, this doesn't automatically make every component faster.&lt;/p&gt;

&lt;p&gt;useMemo has its own overhead and should be used when the calculation is expensive enough to justify it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fixing Unnecessary Child Renders&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Consider:&lt;/p&gt;

&lt;p&gt;function Dashboard() {&lt;br&gt;
  const [search, setSearch] = useState("");&lt;/p&gt;

&lt;p&gt;return (&lt;br&gt;
    &amp;lt;&amp;gt;&lt;br&gt;
      &lt;br&gt;
      &lt;br&gt;
    &amp;lt;/&amp;gt;&lt;br&gt;
  );&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;If Analytics is expensive and doesn't depend on search, repeatedly rendering it may be wasteful.&lt;/p&gt;

&lt;p&gt;You could isolate it:&lt;/p&gt;

&lt;p&gt;import { memo } from "react";&lt;/p&gt;

&lt;p&gt;const Analytics = memo(function Analytics() {&lt;br&gt;
  return (&lt;br&gt;
    &lt;/p&gt;
&lt;br&gt;
      &lt;h2&gt;Analytics&lt;/h2&gt;
&lt;br&gt;
      {/* Expensive chart */}&lt;br&gt;
    &lt;br&gt;
  );&lt;br&gt;
});

&lt;p&gt;Now the component can skip rendering when its props remain unchanged.&lt;/p&gt;

&lt;p&gt;But again, memo is not a universal performance solution.&lt;/p&gt;

&lt;p&gt;If the component receives changing props, it can still render.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;



&lt;p&gt;The object is recreated on each render.&lt;/p&gt;

&lt;p&gt;A memoized component may therefore still see a changed prop reference.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Optimizing Large Lists&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Large lists are a common source of slow rendering.&lt;/p&gt;

&lt;p&gt;Consider:&lt;/p&gt;

&lt;p&gt;function Users({ users }) {&lt;br&gt;
  return (&lt;br&gt;
    &lt;/p&gt;
&lt;br&gt;
      {users.map((user) =&amp;gt; (&lt;br&gt;
        &lt;br&gt;
      ))}&lt;br&gt;
    &lt;br&gt;
  );&lt;br&gt;
}

&lt;p&gt;Rendering 20 users is usually easy.&lt;/p&gt;

&lt;p&gt;Rendering thousands of complex user cards can be expensive.&lt;/p&gt;

&lt;p&gt;In these cases, virtualization can help.&lt;/p&gt;

&lt;p&gt;Instead of rendering every item, virtualization renders only the items currently visible to the user.&lt;/p&gt;

&lt;p&gt;Conceptually:&lt;/p&gt;

&lt;p&gt;10,000 users&lt;/p&gt;

&lt;p&gt;Without virtualization:&lt;br&gt;
████████████████████ 10,000 DOM items&lt;/p&gt;

&lt;p&gt;With virtualization:&lt;br&gt;
██ 20–50 visible items&lt;/p&gt;

&lt;p&gt;This can dramatically reduce initial rendering and scrolling work for very large lists.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using the Browser Performance Panel&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;React Profiler isn't the only performance tool.&lt;/p&gt;

&lt;p&gt;The browser's Performance panel can help investigate problems outside React itself.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;User click&lt;br&gt;
   ↓&lt;br&gt;
React render&lt;br&gt;
   ↓&lt;br&gt;
JavaScript calculation&lt;br&gt;
   ↓&lt;br&gt;
Layout&lt;br&gt;
   ↓&lt;br&gt;
Paint&lt;/p&gt;

&lt;p&gt;A slow interaction may not be caused entirely by React.&lt;/p&gt;

&lt;p&gt;Possible causes include:&lt;/p&gt;

&lt;p&gt;Expensive JavaScript&lt;br&gt;
Layout recalculation&lt;br&gt;
Paint operations&lt;br&gt;
Network requests&lt;br&gt;
Image processing&lt;br&gt;
Long tasks&lt;/p&gt;

&lt;p&gt;This is why experienced developers use multiple tools instead of assuming every performance problem is a React problem.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Measure Before and After&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Suppose your original profile shows:&lt;/p&gt;

&lt;p&gt;OrdersTable: 180 ms&lt;/p&gt;

&lt;p&gt;You optimize the component and profile again:&lt;/p&gt;

&lt;p&gt;OrdersTable: 42 ms&lt;/p&gt;

&lt;p&gt;That's useful evidence.&lt;/p&gt;

&lt;p&gt;But don't stop there.&lt;/p&gt;

&lt;p&gt;Check whether the optimization affected the actual user interaction.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;Before&lt;/p&gt;

&lt;p&gt;Search interaction: 230 ms&lt;/p&gt;

&lt;p&gt;After&lt;/p&gt;

&lt;p&gt;Search interaction: 71 ms&lt;/p&gt;

&lt;p&gt;Now you have a stronger signal that the change helped the user experience.&lt;/p&gt;

&lt;p&gt;The goal isn't:&lt;/p&gt;

&lt;p&gt;"Make the profiler numbers look smaller."&lt;/p&gt;

&lt;p&gt;The goal is:&lt;/p&gt;

&lt;p&gt;Make real interactions faster.&lt;/p&gt;

&lt;p&gt;Best Practices&lt;br&gt;
✅ Do  ❌ Don't&lt;br&gt;
Profile before optimizing   Guess the bottleneck&lt;br&gt;
Reproduce realistic interactions    Test only isolated renders&lt;br&gt;
Fix the largest bottlenecks first   Optimize every component&lt;br&gt;
Measure before and after    Assume an optimization worked&lt;br&gt;
Investigate the cause   Add memo blindly&lt;br&gt;
Check production behavior   Rely only on development timings&lt;br&gt;
Consider browser performance too    Blame React automatically&lt;br&gt;
Common Mistakes&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Adding React.memo Everywhere&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Memoization isn't free.&lt;/p&gt;

&lt;p&gt;If a component is extremely cheap to render, memoizing it may add unnecessary complexity without meaningful benefits.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using useMemo for Everything&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This:&lt;/p&gt;

&lt;p&gt;const result = useMemo(() =&amp;gt; a + b, [a, b]);&lt;/p&gt;

&lt;p&gt;is usually unnecessary.&lt;/p&gt;

&lt;p&gt;The calculation is trivial.&lt;/p&gt;

&lt;p&gt;useMemo becomes more interesting when the calculation is genuinely expensive or when referential stability is important for another optimization.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Optimizing Without Profiling&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Changing five components because you think they might be slow doesn't give you reliable information.&lt;/p&gt;

&lt;p&gt;Profile first.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Only Looking at Render Time&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A component can render quickly while the overall interaction remains slow because of:&lt;/p&gt;

&lt;p&gt;Network requests&lt;br&gt;
JavaScript execution&lt;br&gt;
Layout&lt;br&gt;
Painting&lt;br&gt;
Third-party scripts&lt;/p&gt;

&lt;p&gt;Look at the entire interaction.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Testing Only on a Powerful Computer&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A machine with a high-end CPU may hide performance problems.&lt;/p&gt;

&lt;p&gt;Test on:&lt;/p&gt;

&lt;p&gt;Lower-powered devices&lt;br&gt;
Mobile devices&lt;br&gt;
Realistic datasets&lt;br&gt;
Slower network conditions when relevant&lt;br&gt;
Performance Tips&lt;br&gt;
Keep expensive work out of render&lt;/p&gt;

&lt;p&gt;If something can be calculated once or moved outside the rendering path, consider doing so.&lt;/p&gt;

&lt;p&gt;Keep state local&lt;/p&gt;

&lt;p&gt;Don't make the entire application depend on a state update that only one small component needs.&lt;/p&gt;

&lt;p&gt;Avoid rendering huge lists&lt;/p&gt;

&lt;p&gt;Use pagination, filtering, or virtualization where appropriate.&lt;/p&gt;

&lt;p&gt;Profile real interactions&lt;/p&gt;

&lt;p&gt;Measure the things users actually do:&lt;/p&gt;

&lt;p&gt;Typing&lt;br&gt;
Searching&lt;br&gt;
Opening menus&lt;br&gt;
Navigating&lt;br&gt;
Filtering&lt;br&gt;
Submitting forms&lt;br&gt;
Don't optimize blindly&lt;/p&gt;

&lt;p&gt;Performance work should be evidence-driven.&lt;/p&gt;

&lt;p&gt;Security Considerations&lt;/p&gt;

&lt;p&gt;Performance optimization doesn't replace security.&lt;/p&gt;

&lt;p&gt;When profiling an application:&lt;/p&gt;

&lt;p&gt;Don't expose production user data unnecessarily.&lt;br&gt;
Avoid recording sensitive information in shared screenshots or recordings.&lt;br&gt;
Don't place secrets in client-side code while creating performance tests.&lt;br&gt;
Keep development tooling restricted appropriately in production environments.&lt;br&gt;
Be careful when profiling authenticated applications containing private information.&lt;/p&gt;

&lt;p&gt;Performance tooling should be treated as a development tool, not a reason to expose application data.&lt;/p&gt;

&lt;p&gt;Accessibility Considerations&lt;/p&gt;

&lt;p&gt;Performance and accessibility should be optimized together.&lt;/p&gt;

&lt;p&gt;For example, replacing a normal button with a custom component might appear faster but accidentally remove keyboard accessibility.&lt;/p&gt;

&lt;p&gt;Always preserve:&lt;/p&gt;

&lt;p&gt;Semantic HTML&lt;br&gt;
Keyboard navigation&lt;br&gt;
Focus management&lt;br&gt;
Screen-reader information&lt;br&gt;
Accessible form labels&lt;br&gt;
Appropriate loading states&lt;/p&gt;

&lt;p&gt;A fast interface that is difficult to use is still a poor interface.&lt;/p&gt;

&lt;p&gt;SEO Considerations&lt;/p&gt;

&lt;p&gt;Performance can affect how users experience pages and can contribute to better Core Web Vitals.&lt;/p&gt;

&lt;p&gt;When optimizing React applications:&lt;/p&gt;

&lt;p&gt;Avoid unnecessary JavaScript.&lt;br&gt;
Lazy-load code that isn't immediately needed.&lt;br&gt;
Optimize images.&lt;br&gt;
Reduce expensive client-side rendering where appropriate.&lt;br&gt;
Use server rendering or static rendering when it makes sense for the application.&lt;br&gt;
Keep important content accessible to search engines.&lt;/p&gt;

&lt;p&gt;Don't optimize purely for an SEO score, though.&lt;/p&gt;

&lt;p&gt;A good optimization should improve the experience for real users.&lt;/p&gt;

&lt;p&gt;Real Project Example&lt;/p&gt;

&lt;p&gt;Imagine you're building an e-commerce admin dashboard.&lt;/p&gt;

&lt;p&gt;The page contains:&lt;/p&gt;

&lt;p&gt;Admin Dashboard&lt;br&gt;
│&lt;br&gt;
├── Header&lt;br&gt;
├── Search&lt;br&gt;
├── Revenue Chart&lt;br&gt;
├── Sales Statistics&lt;br&gt;
├── Orders Table&lt;br&gt;
├── Customer List&lt;br&gt;
└── Notifications&lt;/p&gt;

&lt;p&gt;The orders table contains 5,000 records.&lt;/p&gt;

&lt;p&gt;When an administrator types into the search field, the entire page becomes noticeably slower.&lt;/p&gt;

&lt;p&gt;Initial implementation&lt;br&gt;
function Dashboard() {&lt;br&gt;
  const [search, setSearch] = useState("");&lt;/p&gt;

&lt;p&gt;return (&lt;br&gt;
    &amp;lt;&amp;gt;&lt;br&gt;
      &lt;/p&gt;


&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  &amp;lt;RevenueChart /&amp;gt;

  &amp;lt;OrdersTable search={search} /&amp;gt;

  &amp;lt;CustomerList /&amp;gt;
&amp;lt;/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;The profiler reveals that several expensive components render during every search update.&lt;/p&gt;

&lt;p&gt;Investigation&lt;/p&gt;

&lt;p&gt;The profile shows:&lt;/p&gt;

&lt;p&gt;Dashboard       150 ms&lt;br&gt;
OrdersTable     110 ms&lt;br&gt;
CustomerList     25 ms&lt;br&gt;
RevenueChart     15 ms&lt;br&gt;
Search            2 ms&lt;/p&gt;

&lt;p&gt;The search field isn't the problem.&lt;/p&gt;

&lt;p&gt;OrdersTable is.&lt;/p&gt;

&lt;p&gt;Optimization&lt;/p&gt;

&lt;p&gt;The table can be improved by:&lt;/p&gt;

&lt;p&gt;Memoizing expensive derived data when appropriate.&lt;br&gt;
Splitting the table into smaller components.&lt;br&gt;
Memoizing stable child components when profiling shows it helps.&lt;br&gt;
Virtualizing the large list.&lt;br&gt;
Moving unrelated state closer to the components that use it.&lt;/p&gt;

&lt;p&gt;After optimization:&lt;/p&gt;

&lt;p&gt;Dashboard        55 ms&lt;br&gt;
OrdersTable      32 ms&lt;br&gt;
CustomerList     10 ms&lt;br&gt;
RevenueChart      8 ms&lt;br&gt;
Search            2 ms&lt;/p&gt;

&lt;p&gt;More importantly, the search interaction feels substantially more responsive.&lt;/p&gt;

&lt;p&gt;This is the important lesson:&lt;/p&gt;

&lt;p&gt;The profiler helped identify where to investigate instead of relying on assumptions.&lt;/p&gt;

&lt;p&gt;A Practical Profiling Workflow&lt;/p&gt;

&lt;p&gt;When you encounter a slow React interaction, use this checklist:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reproduce the problem
    ↓&lt;/li&gt;
&lt;li&gt;Record the interaction
    ↓&lt;/li&gt;
&lt;li&gt;Find expensive components
    ↓&lt;/li&gt;
&lt;li&gt;Determine why they render
    ↓&lt;/li&gt;
&lt;li&gt;Inspect the component code
    ↓&lt;/li&gt;
&lt;li&gt;Apply one targeted optimization
    ↓&lt;/li&gt;
&lt;li&gt;Record the same interaction again
    ↓&lt;/li&gt;
&lt;li&gt;Compare the results
    ↓&lt;/li&gt;
&lt;li&gt;Verify real user experience&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This approach is much safer than randomly adding memoization throughout an application.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;Performance optimization starts with measurement.&lt;/p&gt;

&lt;p&gt;When a React application feels slow, don't immediately reach for React.memo, useMemo, or useCallback.&lt;/p&gt;

&lt;p&gt;First find out what's actually happening.&lt;/p&gt;

&lt;p&gt;The React Profiler gives you a practical way to investigate rendering behavior and identify components worth examining.&lt;/p&gt;

&lt;p&gt;The most important workflow is:&lt;/p&gt;

&lt;p&gt;Profile → Identify → Understand → Optimize → Measure again.&lt;/p&gt;

&lt;p&gt;Remember that a slow component isn't always caused by React itself. Expensive calculations, large lists, browser layout, network activity, and third-party JavaScript can all contribute to a slow interaction.&lt;/p&gt;

&lt;p&gt;The best React performance optimization is therefore not about using the most optimization techniques.&lt;/p&gt;

&lt;p&gt;It's about using the right technique for the measured problem.&lt;/p&gt;

&lt;p&gt;Discussion&lt;/p&gt;

&lt;p&gt;How do you usually find slow components in your React applications?&lt;/p&gt;

&lt;p&gt;Do you rely on React DevTools Profiler, the browser Performance panel, or a combination of both?&lt;/p&gt;

&lt;p&gt;Share your profiling workflow in the comments.&lt;/p&gt;

&lt;p&gt;About the Author&lt;/p&gt;

&lt;p&gt;Written by Muneeb Ansari&lt;/p&gt;

&lt;p&gt;Founder of BiteGlitz&lt;/p&gt;

&lt;p&gt;I enjoy building modern web applications, AI automation, and sharing practical knowledge with the developer community.&lt;/p&gt;

&lt;p&gt;Website: &lt;a href="https://biteglitz.site%60%60" rel="noopener noreferrer"&gt;https://biteglitz.site``&lt;/a&gt;&lt;/p&gt;

</description>
      <category>frontend</category>
      <category>performance</category>
      <category>react</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Stop Unnecessary Re-renders in React: A Practical Guide to Faster Applications</title>
      <dc:creator>Muneeb Ansari | BiteGlitz</dc:creator>
      <pubDate>Sat, 01 Aug 2026 18:39:22 +0000</pubDate>
      <link>https://dev.to/biteglitz/stop-unnecessary-re-renders-in-react-a-practical-guide-to-faster-applications-c7</link>
      <guid>https://dev.to/biteglitz/stop-unnecessary-re-renders-in-react-a-practical-guide-to-faster-applications-c7</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;React is fast, but that doesn't mean every React application is.&lt;/p&gt;

&lt;p&gt;One of the most common performance problems—especially in growing applications—is &lt;strong&gt;unnecessary re-rendering&lt;/strong&gt;. A small project with a few components may feel instant, but as your application grows, unnecessary renders can cause sluggish interfaces, input lag, excessive CPU usage, and poor user experience.&lt;/p&gt;

&lt;p&gt;The good news is that unnecessary re-renders are usually preventable once you understand &lt;strong&gt;why React re-renders components&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore how React rendering works, learn how to identify performance bottlenecks, and apply practical optimization techniques such as &lt;code&gt;React.memo&lt;/code&gt;, &lt;code&gt;useMemo&lt;/code&gt;, &lt;code&gt;useCallback&lt;/code&gt;, better state management, and component architecture.&lt;/p&gt;

&lt;p&gt;Whether you're building dashboards, e-commerce stores, SaaS products, or portfolio websites, these techniques will help you write more efficient React applications.&lt;/p&gt;




&lt;h1&gt;
  
  
  Table of Contents
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Understanding React Rendering&lt;/li&gt;
&lt;li&gt;What Causes Unnecessary Re-renders?&lt;/li&gt;
&lt;li&gt;Identifying Performance Problems&lt;/li&gt;
&lt;li&gt;Optimizing with React.memo&lt;/li&gt;
&lt;li&gt;Optimizing Expensive Calculations with useMemo&lt;/li&gt;
&lt;li&gt;Preventing Function Recreation with useCallback&lt;/li&gt;
&lt;li&gt;State Colocation&lt;/li&gt;
&lt;li&gt;Splitting Components&lt;/li&gt;
&lt;li&gt;Optimizing Context&lt;/li&gt;
&lt;li&gt;Rendering Large Lists&lt;/li&gt;
&lt;li&gt;Using the React Profiler&lt;/li&gt;
&lt;li&gt;Best Practices&lt;/li&gt;
&lt;li&gt;Common Mistakes&lt;/li&gt;
&lt;li&gt;Performance Tips&lt;/li&gt;
&lt;li&gt;Security Considerations&lt;/li&gt;
&lt;li&gt;Accessibility Considerations&lt;/li&gt;
&lt;li&gt;SEO Considerations&lt;/li&gt;
&lt;li&gt;Real Project Example&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;li&gt;Discussion&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  Background
&lt;/h1&gt;

&lt;p&gt;Before optimizing anything, it's important to understand what React actually does.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;render&lt;/strong&gt; simply means React executes your component function to determine what the UI should look like.&lt;/p&gt;

&lt;p&gt;That &lt;strong&gt;does not always mean the browser updates the DOM&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;React compares the new Virtual DOM with the previous one and only updates the parts that actually changed.&lt;/p&gt;

&lt;p&gt;However, if many components re-render unnecessarily, React still has to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Execute component functions&lt;/li&gt;
&lt;li&gt;Recreate objects&lt;/li&gt;
&lt;li&gt;Recreate arrays&lt;/li&gt;
&lt;li&gt;Recreate event handlers&lt;/li&gt;
&lt;li&gt;Compare Virtual DOM trees&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of that work adds up.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 1 — Why Components Re-render
&lt;/h1&gt;

&lt;p&gt;Components typically re-render when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Their state changes&lt;/li&gt;
&lt;li&gt;Their props change&lt;/li&gt;
&lt;li&gt;Their parent re-renders&lt;/li&gt;
&lt;li&gt;Context values change&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Parent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;

      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Child&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even though &lt;code&gt;Child&lt;/code&gt; doesn't use &lt;code&gt;count&lt;/code&gt;, it still re-renders because its parent re-rendered.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 2 — Prevent Re-renders with React.memo
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;React.memo&lt;/code&gt; tells React to skip rendering if the component's props haven't changed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Child&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;memo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;Child&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Rendered&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now clicking the counter won't re-render &lt;code&gt;Child&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use React.memo when
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Components receive the same props frequently&lt;/li&gt;
&lt;li&gt;Components are expensive to render&lt;/li&gt;
&lt;li&gt;Lists contain many items&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Avoid wrapping every component in &lt;code&gt;React.memo&lt;/code&gt;. It also has a comparison cost.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 3 — Expensive Calculations with useMemo
&lt;/h1&gt;

&lt;p&gt;Bad example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sortedUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;compareUsers&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sorting happens every render.&lt;/p&gt;

&lt;p&gt;Better:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sortedUsers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMemo&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[...&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;compareUsers&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now sorting only runs when &lt;code&gt;users&lt;/code&gt; changes.&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;useMemo&lt;/code&gt; for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Filtering&lt;/li&gt;
&lt;li&gt;Sorting&lt;/li&gt;
&lt;li&gt;Large calculations&lt;/li&gt;
&lt;li&gt;Data transformations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't use it for trivial computations.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 4 — Stable Functions with useCallback
&lt;/h1&gt;

&lt;p&gt;Functions are recreated every render.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Child&lt;/span&gt; &lt;span class="na"&gt;onDelete&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;React sees a new function each render.&lt;/p&gt;

&lt;p&gt;Instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleDelete&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCallback&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Child&lt;/span&gt; &lt;span class="na"&gt;onDelete&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleDelete&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This becomes especially useful when passing callbacks to memoized components.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 5 — Move State Closer to Where It's Used
&lt;/h1&gt;

&lt;p&gt;Many developers keep state at the top level.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;App
 ├── Navbar
 ├── Sidebar
 ├── Dashboard
 └── Footer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If &lt;code&gt;App&lt;/code&gt; stores every piece of state, updating one small input causes everything below it to re-render.&lt;/p&gt;

&lt;p&gt;Instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dashboard
   └── SearchBox
        └── search state
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep state as close as possible to the component that needs it.&lt;/p&gt;

&lt;p&gt;This is called &lt;strong&gt;state colocation&lt;/strong&gt;, and it reduces unnecessary renders.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 6 — Split Large Components
&lt;/h1&gt;

&lt;p&gt;Instead of one giant component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;Dashboard&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Split into:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dashboard
├── Sidebar
├── Analytics
├── Orders
├── Charts
└── Settings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Smaller components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Render independently&lt;/li&gt;
&lt;li&gt;Are easier to test&lt;/li&gt;
&lt;li&gt;Improve readability&lt;/li&gt;
&lt;li&gt;Reduce unnecessary updates&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Step 7 — Optimize React Context
&lt;/h1&gt;

&lt;p&gt;A common mistake:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AppContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Provider&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whenever &lt;strong&gt;either&lt;/strong&gt; &lt;code&gt;user&lt;/code&gt; or &lt;code&gt;theme&lt;/code&gt; changes, every consumer re-renders.&lt;/p&gt;

&lt;p&gt;Better:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UserContext
ThemeContext
SettingsContext
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Split unrelated state into separate contexts.&lt;/p&gt;

&lt;p&gt;This keeps updates localized.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 8 — Optimize Lists
&lt;/h1&gt;

&lt;p&gt;Never use array indexes as keys unless the list is static.&lt;/p&gt;

&lt;p&gt;Bad:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Better:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Stable keys help React efficiently reconcile list items.&lt;/p&gt;

&lt;p&gt;For very large datasets, consider list virtualization libraries such as &lt;code&gt;react-window&lt;/code&gt; or &lt;code&gt;react-virtualized&lt;/code&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step 9 — Measure with React Profiler
&lt;/h1&gt;

&lt;p&gt;Optimization without measurement is guesswork.&lt;/p&gt;

&lt;p&gt;React DevTools includes the &lt;strong&gt;Profiler&lt;/strong&gt;, which shows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which components rendered&lt;/li&gt;
&lt;li&gt;Why they rendered&lt;/li&gt;
&lt;li&gt;Render duration&lt;/li&gt;
&lt;li&gt;Performance bottlenecks&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Workflow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open React DevTools.&lt;/li&gt;
&lt;li&gt;Switch to the &lt;strong&gt;Profiler&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;Record interactions.&lt;/li&gt;
&lt;li&gt;Identify components with frequent or expensive renders.&lt;/li&gt;
&lt;li&gt;Optimize only where it makes a measurable difference.&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  Best Practices
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;✅ Do&lt;/th&gt;
&lt;th&gt;❌ Don't&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Measure before optimizing&lt;/td&gt;
&lt;td&gt;Optimize blindly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Keep components small&lt;/td&gt;
&lt;td&gt;Create huge components&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Use stable keys&lt;/td&gt;
&lt;td&gt;Use array indexes unnecessarily&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Memoize expensive calculations&lt;/td&gt;
&lt;td&gt;Memoize everything&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Keep state local&lt;/td&gt;
&lt;td&gt;Lift all state to the root&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Profile regularly&lt;/td&gt;
&lt;td&gt;Assume React is the bottleneck&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  Common Mistakes
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Memoizing Everything
&lt;/h3&gt;

&lt;p&gt;More memoization isn't always faster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inline Objects
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Component&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;red&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A new object is created every render.&lt;/p&gt;

&lt;p&gt;Prefer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useMemo&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;red&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;when the object is passed to memoized children or used as a dependency.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ignoring the Profiler
&lt;/h3&gt;

&lt;p&gt;Developers often optimize code based on assumptions instead of evidence.&lt;/p&gt;




&lt;h1&gt;
  
  
  Performance Tips
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Lazy-load large pages with &lt;code&gt;React.lazy&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Use code splitting.&lt;/li&gt;
&lt;li&gt;Debounce search inputs.&lt;/li&gt;
&lt;li&gt;Virtualize long lists.&lt;/li&gt;
&lt;li&gt;Avoid unnecessary context updates.&lt;/li&gt;
&lt;li&gt;Remove unused dependencies.&lt;/li&gt;
&lt;li&gt;Cache API responses where appropriate.&lt;/li&gt;
&lt;li&gt;Minimize expensive computations during render.&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Security Tips
&lt;/h1&gt;

&lt;p&gt;Performance optimizations should never compromise security.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Never trust client-side validation alone.&lt;/li&gt;
&lt;li&gt;Sanitize user-generated HTML before rendering it.&lt;/li&gt;
&lt;li&gt;Avoid exposing sensitive data in React state if it's not needed.&lt;/li&gt;
&lt;li&gt;Store authentication tokens securely and follow your application's security model.&lt;/li&gt;
&lt;li&gt;Keep dependencies up to date to receive security and performance fixes.&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Accessibility Tips
&lt;/h1&gt;

&lt;p&gt;Fast applications should also be accessible.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use semantic HTML.&lt;/li&gt;
&lt;li&gt;Ensure interactive elements are keyboard accessible.&lt;/li&gt;
&lt;li&gt;Preserve visible focus indicators.&lt;/li&gt;
&lt;li&gt;Add descriptive labels to form controls.&lt;/li&gt;
&lt;li&gt;Test with screen readers after performance optimizations to ensure behavior hasn't changed.&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  SEO Tips
&lt;/h1&gt;

&lt;p&gt;For React applications:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use descriptive page titles.&lt;/li&gt;
&lt;li&gt;Add meaningful meta descriptions.&lt;/li&gt;
&lt;li&gt;Render important content in a way search engines can access (SSR or static rendering when appropriate).&lt;/li&gt;
&lt;li&gt;Optimize images and use descriptive alt text.&lt;/li&gt;
&lt;li&gt;Avoid blocking rendering with unnecessary JavaScript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Performance improvements also contribute to better Core Web Vitals, which can positively influence search visibility.&lt;/p&gt;




&lt;h1&gt;
  
  
  Real Project Example
&lt;/h1&gt;

&lt;p&gt;Imagine an admin dashboard with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Analytics charts&lt;/li&gt;
&lt;li&gt;User management&lt;/li&gt;
&lt;li&gt;Notifications&lt;/li&gt;
&lt;li&gt;Recent orders&lt;/li&gt;
&lt;li&gt;Search filters&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Initially, every keystroke in the search bar caused the entire dashboard to re-render.&lt;/p&gt;

&lt;p&gt;After refactoring:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search state was moved into the search component.&lt;/li&gt;
&lt;li&gt;Chart components were wrapped with &lt;code&gt;React.memo&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Filtered data was memoized with &lt;code&gt;useMemo&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Event handlers were stabilized with &lt;code&gt;useCallback&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Context was split into separate providers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The result was a noticeably smoother interface, especially on lower-powered devices, with fewer wasted renders and improved responsiveness.&lt;/p&gt;




&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Unnecessary re-renders are one of the most common reasons React applications slow down as they grow.&lt;/p&gt;

&lt;p&gt;The key takeaway isn't to memoize every component—it's to understand &lt;strong&gt;why&lt;/strong&gt; React is rendering in the first place.&lt;/p&gt;

&lt;p&gt;A good optimization workflow is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Measure with the React Profiler.&lt;/li&gt;
&lt;li&gt;Identify expensive or frequent renders.&lt;/li&gt;
&lt;li&gt;Apply targeted optimizations.&lt;/li&gt;
&lt;li&gt;Measure again to confirm the improvement.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By combining thoughtful component design, localized state, memoization where appropriate, and regular profiling, you can build React applications that remain fast and maintainable as they scale.&lt;/p&gt;




&lt;h1&gt;
  
  
  Discussion
&lt;/h1&gt;

&lt;p&gt;How do you identify unnecessary re-renders in your React projects?&lt;/p&gt;

&lt;p&gt;Do you rely mostly on the React Profiler, or do you have other techniques that help you track down performance issues?&lt;/p&gt;

&lt;p&gt;I'd love to hear your approach and learn from your experience.&lt;/p&gt;




&lt;h2&gt;
  
  
  About the Author
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Written by Muneeb Ansari&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Founder of BiteGlitz&lt;/p&gt;

&lt;p&gt;I enjoy building modern web applications, AI automation, and sharing practical knowledge with the developer community.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://biteglitz.site" rel="noopener noreferrer"&gt;https://biteglitz.site&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>performance</category>
      <category>react</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
