<?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: Purvi Sondarva</title>
    <description>The latest articles on DEV Community by Purvi Sondarva (@purvisondarva).</description>
    <link>https://dev.to/purvisondarva</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%2F4186670%2Fe0370f4b-e29e-4c28-a53f-5774b0095366.jpg</url>
      <title>DEV Community: Purvi Sondarva</title>
      <link>https://dev.to/purvisondarva</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/purvisondarva"/>
    <language>en</language>
    <item>
      <title>Do You Still Need useMemo and useCallback After React Compiler?</title>
      <dc:creator>Purvi Sondarva</dc:creator>
      <pubDate>Mon, 23 Nov 2026 12:11:03 +0000</pubDate>
      <link>https://dev.to/purvisondarva/do-you-still-need-usememo-and-usecallback-after-react-compiler-507n</link>
      <guid>https://dev.to/purvisondarva/do-you-still-need-usememo-and-usecallback-after-react-compiler-507n</guid>
      <description>&lt;p&gt;Open almost any React codebase written in the last few years, and you'll find it: &lt;code&gt;useMemo&lt;/code&gt; around a &lt;code&gt;simple .filter(), useCallback&lt;/code&gt; around every handler, &lt;code&gt;memo()&lt;/code&gt; on components that render twice a day.&lt;/p&gt;

&lt;p&gt;We added all that code to stop unnecessary re-renders. Now React Compiler does memoization automatically at build time. So the obvious question is: &lt;strong&gt;do you still need useMemo and useCallback after React Compiler?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short answer&lt;/strong&gt;: for most new code, no. But there are a few cases where removing them will hurt you, and a few things the compiler will never fix for you.&lt;/p&gt;

&lt;p&gt;This post covers both, with code you can compare side by side.&lt;/p&gt;

&lt;p&gt;📌 This is part 2 of my &lt;strong&gt;React Performance in Practice&lt;/strong&gt; series. In &lt;a href="https://dev.to/purvisondarva/react-performance-debugging-find-and-fix-unnecessary-re-renders-with-real-examples-57l0"&gt;part 1&lt;/a&gt;, I showed how to find unnecessary re-renders with React DevTools. This post explains what to do once you find them.&lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;React Compiler memoizes components, values, and callbacks for you, often more precisely than hand-written hooks.&lt;/li&gt;
&lt;li&gt;In new code, write plain React and let the compiler handle memoization.&lt;/li&gt;
&lt;li&gt;Keep &lt;code&gt;useMemo / useCallback&lt;/code&gt; when a value is an effect dependency, and you need exact control over when the effect runs.&lt;/li&gt;
&lt;li&gt;The compiler assumes you follow the Rules of React. Code that mutates props or reads refs during render can break or be skipped.&lt;/li&gt;
&lt;li&gt;The compiler doesn't fix bad state placement, chatty context, huge lists, or slow data fetching.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What does React Compiler actually do?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://react.dev/learn/react-compiler/introduction" rel="noopener noreferrer"&gt;React Compiler&lt;/a&gt; is a build-time tool that analyzes your components and hooks and automatically inserts memoization. It caches computed values, callbacks, and JSX, and recalculates them only when their inputs change. You get the effect of &lt;code&gt;useMemo&lt;/code&gt;, &lt;code&gt;useCallback&lt;/code&gt;, and &lt;code&gt;memo()&lt;/code&gt; without writing them.&lt;/p&gt;

&lt;p&gt;It runs as a Babel plugin (&lt;code&gt;babel-plugin-react-compiler&lt;/code&gt;). It reached its &lt;a href="https://react.dev/blog/2025/10/07/react-compiler-1" rel="noopener noreferrer"&gt;stable 1.0 release in October 2025&lt;/a&gt; and works best with React 19.&lt;/p&gt;

&lt;p&gt;Here's a typical component written the "careful" way:&lt;/p&gt;

&lt;p&gt;jsx&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;useMemo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;useCallback&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;memo&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'react'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;ProductList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;onAddToCart&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;filtered&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="p"&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="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
        &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&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="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;handleAdd&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;id&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;onAddToCart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&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="n"&gt;onAddToCart&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="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ul&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;filtered&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ProductRow&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;onAdd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;handleAdd&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;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;ul&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;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nc"&gt;ProductRow&lt;/span&gt; &lt;span class="o"&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="nc"&gt;ProductRow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;onAdd&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="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt; &lt;span class="n"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;onAdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&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="nc"&gt;Add&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;li&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;;&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And here's the same component with the compiler turned on:&lt;/p&gt;

&lt;p&gt;jsx&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="nc"&gt;ProductList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;onAddToCart&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;filtered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&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="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&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="p"&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ul&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;filtered&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;p&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ProductRow&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;onAdd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;onAddToCart&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;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;ul&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;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;ProductRow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;onAdd&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="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt; &lt;span class="n"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;onAdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&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="nc"&gt;Add&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;button&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;li&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;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same behavior, less code, and nothing to keep in sync. No dependency arrays to forget.&lt;/p&gt;

&lt;p&gt;Under the hood, the compiled output looks roughly like this (simplified):&lt;/p&gt;

&lt;p&gt;js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nc"&gt;JavaScript&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;ProductList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;props&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="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;_c&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// compiler-managed cache slots&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;onAddToCart&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;props&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;filtered&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&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="o"&gt;!==&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; $&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;filtered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="cm"&gt;/* ... */&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="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;products&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    $&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    $&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;filtered&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;filtered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; $&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&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="c1"&gt;// JSX is cached the same way&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One detail I like here: the compiler can memoize things &lt;strong&gt;after an early return or inside conditions&lt;/strong&gt;. Hooks can't go there so that the compiler can be more precise than hand-written &lt;code&gt;useMemo&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  So, should you delete every useMemo and useCallback?
&lt;/h2&gt;

&lt;p&gt;Not blindly. For new code, write it without manual memoization. For existing code, the React team recommends leaving current &lt;code&gt;useMemo / useCallback&lt;/code&gt; in place and removing them only after testing, because removing them can change what the compiler produces.&lt;/p&gt;

&lt;p&gt;Here's the quick decision table I use:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foa6ph7lqraxip9f4exsf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Foa6ph7lqraxip9f4exsf.png" alt=" " width="760" height="618"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next two sections explain the rows that catch people out.&lt;/p&gt;

&lt;h2&gt;
  
  
  When does useMemo still matter? Effect dependencies
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;useMemo&lt;/code&gt; and &lt;code&gt;useCallback&lt;/code&gt; still matter when a value feeds a useEffect and correctness depends on that value staying stable. The compiler's memoization is a performance optimization, not a guarantee, so if your effect must not re-run, make that explicit.&lt;/p&gt;

&lt;p&gt;Classic example: a chat room that reconnects whenever options change.&lt;/p&gt;

&lt;p&gt;jsx&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="nc"&gt;ChatRoom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;roomId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;serverUrl&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;roomId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;serverUrl&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// new object every render&lt;/span&gt;

  &lt;span class="nf"&gt;useEffect&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;connection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createConnection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&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="k"&gt;return&lt;/span&gt; &lt;span class="p"&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="n"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;disconnect&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="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;options&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="c1"&gt;// 😬 relies on memoization to avoid reconnecting&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The compiler will probably memoize &lt;code&gt;options&lt;/code&gt;. But "probably" isn't what you want for a WebSocket connection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best fix&lt;/strong&gt;: don't need memoization at all. Move the object inside the effect and depend on primitives(the React docs cover this pattern in &lt;a href="https://react.dev/learn/removing-effect-dependencies" rel="noopener noreferrer"&gt;Removing Effect Dependencies&lt;/a&gt;):&lt;/p&gt;

&lt;p&gt;jsx&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="nc"&gt;ChatRoom&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;roomId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;serverUrl&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="nf"&gt;useEffect&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;connection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;createConnection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;roomId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;serverUrl&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="n"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&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="k"&gt;return&lt;/span&gt; &lt;span class="p"&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;connectiondisconnect&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="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;roomId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;serverUrl&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="c1"&gt;// ✅ only reconnects when these change&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;If you can't restructure it&lt;/strong&gt; (for example, the object comes from a custom hook that other code also uses), keep an explicit useMemo. This is exactly the escape hatch it's meant for:&lt;/p&gt;

&lt;p&gt;jsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;options&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="p"&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="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;roomId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;serverUrl&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="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;roomId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;serverUrl&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rule of thumb: &lt;strong&gt;if removing memoization would change behavior, not just speed, keep it explicit&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why does the compiler skip some components?
&lt;/h2&gt;

&lt;p&gt;React Compiler assumes your code follows the Rules of React: components are pure, props and state are treated as immutable, and refs aren't read during render. When it detects a violation, it skips optimizing that component. When it can't detect one, you can end up with stale UI.&lt;/p&gt;

&lt;p&gt;Here's a bug I see a lot:&lt;/p&gt;

&lt;p&gt;jsx&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="nc"&gt;Leaderboard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;scores&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="n"&gt;scores&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ❌ mutates a prop&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ol&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;scores&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;li&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&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="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&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="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;li&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;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;ol&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;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;.sort()&lt;/code&gt; mutates the array in place. Without the compiler, this "works" by accident. With caching, mutated inputs are exactly what leads to confusing bugs.&lt;/p&gt;

&lt;p&gt;The fix is one word:&lt;/p&gt;

&lt;p&gt;jsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;sorted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toSorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ✅ returns a new array&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other common offenders:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reading &lt;code&gt;ref.current&lt;/code&gt; during render instead of in effects or handlers&lt;/li&gt;
&lt;li&gt;Mutating an object from state and then calling &lt;code&gt;setState&lt;/code&gt; with the same reference&lt;/li&gt;
&lt;li&gt;Side effects such as analytics calls or &lt;code&gt;localStorage&lt;/code&gt; writes in the render body&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;: Install the latest &lt;a href="https://react.dev/reference/eslint-plugin-react-hooks" rel="noopener noreferrer"&gt;eslint-plugin-react-hooks&lt;/a&gt;. Its recommended config now includes compiler-aware rules that flag these patterns before they reach production.&lt;/p&gt;

&lt;h2&gt;
  
  
  What React Compiler will NOT fix
&lt;/h2&gt;

&lt;p&gt;This is the part most "React Compiler explained" posts skip. Memoization stops unnecessary work. It doesn't make necessary work cheaper, and it doesn't fix architecture.&lt;/p&gt;

&lt;p&gt;When we run performance audits on production React apps, the real bottleneck is usually one of these, and none of them go away with the compiler:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;State that lives too high&lt;/strong&gt;. If a search input's state lives in your root layout, the layout re-renders on every keystroke. Move state closer to where it's used.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context that changes constantly&lt;/strong&gt;. Every consumer re-renders when a context value changes. Split fast-changing values (cursor position, timers) from slow ones (user, theme).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rendering thousands of rows&lt;/strong&gt;. Caching doesn't help if 5,000 DOM nodes are on screen. Use virtualization, for example, &lt;code&gt;[react-window](https://github.com/bvaughn/react-window)&lt;/code&gt; or &lt;a href="https://tanstack.com/virtual/latest" rel="noopener noreferrer"&gt;TanStack Virtual&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Slow data fetching&lt;/strong&gt;. Request waterfalls, missing caching, and oversized API payloads are network problems, not render problems.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Large bundles&lt;/strong&gt;. The compiler doesn't code-split for you. Lazy-load heavy routes and libraries.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If your app still feels slow after turning the compiler on, start with this list. It's also where React performance optimization work usually pays off the most, because fixing one of these often matters more than fifty &lt;code&gt;useMemo&lt;/code&gt; calls.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to check the compiler is working
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;React DevTools&lt;/strong&gt;: optimized components show a "&lt;strong&gt;Memo&lt;/strong&gt;" badge in the Components tab.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ESLint&lt;/strong&gt;: fix anything the compiler-related rules in &lt;code&gt;eslint-plugin-react-hooks&lt;/code&gt; report.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Profiler&lt;/strong&gt;: record the same interaction before and after enabling the compiler and compare commit counts. This is the same workflow from &lt;a href="https://dev.to/purvisondarva/react-performance-debugging-find-and-fix-unnecessary-re-renders-with-real-examples-57l0"&gt;part 1&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Opt out to debug:&lt;/strong&gt; If a component behaves strangely, add &lt;code&gt;"use no memo"&lt;/code&gt; at the top of its function to skip compilation for just that component while you investigate.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Quick setup
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Next.js&lt;/strong&gt; (install &lt;code&gt;babel-plugin-react-compiler&lt;/code&gt; first; see the &lt;a href="https://nextjs.org/docs/app/api-reference/config/next-config-js/reactCompiler" rel="noopener noreferrer"&gt;Next.js reactCompiler docs&lt;/a&gt;):&lt;/p&gt;

&lt;p&gt;js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// next.config.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;nextConfig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;reactCompiler&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&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="kd"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nextConfig&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Vite&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// vite.config.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;defineConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'vite'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;react&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@vitejs/plugin-react'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nf"&gt;react&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;babel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'babel-plugin-react-compiler'&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="p"&gt;,&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="p"&gt;]&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="p"&gt;;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On React 17 or 18? You'll also need the &lt;code&gt;react-compiler-runtime&lt;/code&gt; package and the &lt;code&gt;target&lt;/code&gt; option set in the compiler config. Check the official docs for your version.&lt;/p&gt;

&lt;h2&gt;
  
  
  Migration checklist for an existing codebase
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Upgrade &lt;code&gt;eslint-plugin-react-hooks&lt;/code&gt; and fix Rules of React violations first&lt;/li&gt;
&lt;li&gt;[ ] Enable the compiler on one folder or route (use &lt;code&gt;compilationMode: 'annotation'&lt;/code&gt; with &lt;code&gt;"use memo"&lt;/code&gt; if you want gradual rollout)&lt;/li&gt;
&lt;li&gt;[ ] Run your test suite and click through critical flows&lt;/li&gt;
&lt;li&gt;[ ] Compare before and after with the React Profiler&lt;/li&gt;
&lt;li&gt;[ ] Expand to the whole app&lt;/li&gt;
&lt;li&gt;[ ] Remove old &lt;code&gt;useMemo / useCallback / memo()&lt;/code&gt; one file at a time, testing as you go&lt;/li&gt;
&lt;li&gt;[ ] Keep explicit memoization wherever an effect depends on stable references&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;React Compiler changes the default. Instead of asking "should I memoize this?", you write plain React and only reach for &lt;code&gt;useMemo&lt;/code&gt; or &lt;code&gt;useCallback&lt;/code&gt; when stability affects &lt;strong&gt;correctness&lt;/strong&gt;, not just speed.&lt;/p&gt;

&lt;p&gt;The bigger wins still come from getting the fundamentals right: state in the right place, lean context, virtualized lists, and fast data fetching.&lt;/p&gt;

&lt;p&gt;Now I'm curious: have you turned on React Compiler in a real project yet? Did you delete your &lt;code&gt;useMemo&lt;/code&gt; calls, or are you keeping them "just in case"? Tell me in the comments 👇&lt;/p&gt;

&lt;p&gt;Next in this series: how to fix slow React Context without reaching for a state library. Follow so you don't miss it.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>performance</category>
    </item>
    <item>
      <title>React Performance Debugging: Find and Fix Unnecessary Re-Renders with Real Examples</title>
      <dc:creator>Purvi Sondarva</dc:creator>
      <pubDate>Thu, 15 Oct 2026 11:56:05 +0000</pubDate>
      <link>https://dev.to/purvisondarva/react-performance-debugging-find-and-fix-unnecessary-re-renders-with-real-examples-57l0</link>
      <guid>https://dev.to/purvisondarva/react-performance-debugging-find-and-fix-unnecessary-re-renders-with-real-examples-57l0</guid>
      <description>&lt;p&gt;Have you ever clicked a button in a React application and noticed that components you didn't touch were rendering again?&lt;/p&gt;

&lt;p&gt;Maybe a dashboard feels sluggish when updating a counter. Perhaps a large list becomes slow when typing into a search field. Or maybe you've added &lt;code&gt;React. memo, useMemo,&lt;/code&gt; and &lt;code&gt;useCallback&lt;/code&gt;, but the performance hasn't improved much.&lt;/p&gt;

&lt;p&gt;These problems are common in React applications, but the solution isn't to add memoization everywhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The first step is to identify what is rendering, why it is rendering, and whether that rendering is actually expensive.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll investigate unnecessary React re-renders, reproduce a common problem, fix it with practical code, and learn how to verify whether the optimization works.&lt;/p&gt;

&lt;h2&gt;
  
  
  What causes unnecessary re-renders in React?
&lt;/h2&gt;

&lt;p&gt;A React component can render again when its state changes, its parent renders, or its consumed context changes. External store subscriptions and other React mechanisms can also trigger updates.&lt;/p&gt;

&lt;p&gt;A render isn't necessarily a problem. React is designed to render components when needed.&lt;/p&gt;

&lt;p&gt;The real problem occurs when an interaction triggers expensive work that doesn't need to happen.&lt;/p&gt;

&lt;p&gt;For example, imagine a dashboard containing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A counter that updates frequently.&lt;/li&gt;
&lt;li&gt;A user profile card.&lt;/li&gt;
&lt;li&gt;A large table containing hundreds of records.&lt;/li&gt;
&lt;li&gt;Several charts with expensive calculations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If updating the counter also causes expensive components to render repeatedly, the application may feel slower than necessary.&lt;/p&gt;

&lt;p&gt;Here are four common causes worth investigating:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe66m6fmq52b7sidi2sl4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe66m6fmq52b7sidi2sl4.png" alt=" " width="771" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The important distinction is that a component rendering again does not automatically mean it should be optimized. Start by finding measurable performance problems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Reproduce an unnecessary re-render
&lt;/h3&gt;

&lt;p&gt;Let's consider a small dashboard. It has a counter and a user profile component.&lt;/p&gt;

&lt;p&gt;The profile doesn't depend on the counter, but it renders again whenever the counter changes.&lt;/p&gt;

&lt;p&gt;Here's the simplified implementation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { memo, useState } from "react";

const UserProfile = memo(function UserProfile({ user }) {
  console.log("UserProfile rendered");

  return (
    &amp;lt;section&amp;gt;
      &amp;lt;h2&amp;gt;{user.name}&amp;lt;/h2&amp;gt;
      &amp;lt;p&amp;gt;{user.role}&amp;lt;/p&amp;gt;
    &amp;lt;/section&amp;gt;
  );
});

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

  const user = {
    name: "Alex",
    role: "Frontend Engineer",
  };

  return (
    &amp;lt;main&amp;gt;
      &amp;lt;h1&amp;gt;Dashboard&amp;lt;/h1&amp;gt;

      &amp;lt;button onClick={() =&amp;gt; setCount(count + 1)}&amp;gt;
        Count: {count}
      &amp;lt;/button&amp;gt;

      &amp;lt;UserProfile user={user} /&amp;gt;
    &amp;lt;/main&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first glance, this looks reasonable. The profile component is already wrapped in memo, so why does it render again?&lt;/p&gt;

&lt;p&gt;The problem is this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const user = {
  name: "Alex",
  role: "Frontend Engineer",
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every time &lt;code&gt;Dashboard&lt;/code&gt; renders, JavaScript creates a new object.&lt;/p&gt;

&lt;p&gt;Even though the object's properties are unchanged, its reference is different. React's default memoization comparison sees the new &lt;code&gt;user&lt;/code&gt; prop as changed, so &lt;code&gt;UserProfile&lt;/code&gt; cannot skip rendering because of &lt;code&gt;memo&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This is a common source of confusion: identical object contents do not mean identical object references.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Find the problem with React DevTools Profiler
&lt;/h3&gt;

&lt;p&gt;Before changing the code, confirm what is happening.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://react.dev/learn/react-developer-tools" rel="noopener noreferrer"&gt;React Developer Tools&lt;/a&gt; extension includes Components and Profiler panels that help you inspect components and investigate rendering behavior.&lt;/p&gt;

&lt;p&gt;Here's a practical debugging workflow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open your application in the browser.&lt;/li&gt;
&lt;li&gt;Open React DevTools and select the Profiler tab.&lt;/li&gt;
&lt;li&gt;Start recording.&lt;/li&gt;
&lt;li&gt;Perform the interaction that feels slow, such as clicking the counter repeatedly.&lt;/li&gt;
&lt;li&gt;Stop recording and inspect the components involved in each commit.&lt;/li&gt;
&lt;li&gt;Look for expensive rendering work or components that repeatedly render without needing updated data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Don't focus only on how many times a component renders. A component that renders frequently but takes very little time may not be worth optimizing.&lt;br&gt;
Instead, look for repeated work associated with a noticeably slow interaction.&lt;/p&gt;

&lt;p&gt;For a deeper investigation, React's &lt;a href="https://react.dev/reference/react/Profiler" rel="noopener noreferrer"&gt;Profiler API&lt;/a&gt; can measure rendering performance programmatically.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 3: Fix the unstable object reference
&lt;/h3&gt;

&lt;p&gt;One possible fix is to memoize the user object with &lt;code&gt;useMemo&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { memo, useMemo, useState } from "react";

const UserProfile = memo(function UserProfile({ user }) {
  console.log("UserProfile rendered");

  return (
    &amp;lt;section&amp;gt;
      &amp;lt;h2&amp;gt;{user.name}&amp;lt;/h2&amp;gt;
      &amp;lt;p&amp;gt;{user.role}&amp;lt;/p&amp;gt;
    &amp;lt;/section&amp;gt;
  );
});

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

  const user = useMemo(
    () =&amp;gt; ({
      name: "Alex",
      role: "Frontend Engineer",
    }),
    []
  );

  return (
    &amp;lt;main&amp;gt;
      &amp;lt;h1&amp;gt;Dashboard&amp;lt;/h1&amp;gt;

      &amp;lt;button onClick={() =&amp;gt; setCount(count + 1)}&amp;gt;
        Count: {count}
      &amp;lt;/button&amp;gt;

      &amp;lt;UserProfile user={user} /&amp;gt;
    &amp;lt;/main&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the object reference stays stable between renders, as long as the dependencies don't change.&lt;/p&gt;

&lt;p&gt;When the counter updates, &lt;code&gt;UserProfile&lt;/code&gt; can skip rendering because its user prop has not changed.&lt;/p&gt;

&lt;p&gt;This works because two things are happening together:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;useMemo&lt;/code&gt; preserves the calculated object between renders.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;memo&lt;/code&gt; lets the child skip rendering when its props remain unchanged.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using &lt;code&gt;useMemo&lt;/code&gt; without a reason isn't automatically beneficial. If the object is cheap to create and the child isn't memoized, the optimization may provide no meaningful improvement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A simpler alternative&lt;/strong&gt;: If the object is constant, move it outside the component entirely.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const user = {
  name: "Alex",
  role: "Frontend Engineer",
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is often easier to understand when the data doesn't depend on props, state, or other reactive values.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Fix unstable function props
&lt;/h3&gt;

&lt;p&gt;Objects aren't the only issue. Functions can also prevent memoized components from skipping renders.&lt;/p&gt;

&lt;p&gt;Consider this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const SaveButton = memo(function SaveButton({ onSave }) {
  console.log("SaveButton rendered");

  return &amp;lt;button onClick={onSave}&amp;gt;Save changes&amp;lt;/button&amp;gt;;
});

function Editor() {
  const [count, setCount] = useState(0);

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setCount(count + 1)}&amp;gt;
        Counter: {count}
      &amp;lt;/button&amp;gt;

      &amp;lt;SaveButton onSave={() =&amp;gt; console.log("Saved")} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The inline function passed to &lt;code&gt;SaveButton&lt;/code&gt; is a new function reference on each render. Consequently, &lt;code&gt;memo&lt;/code&gt; cannot skip the child render based on unchanged props.&lt;/p&gt;

&lt;p&gt;If profiling confirms that this child is worth optimizing, &lt;code&gt;useCallback&lt;/code&gt; can preserve the function reference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { memo, useCallback, useState } from "react";

const SaveButton = memo(function SaveButton({ onSave }) {
  console.log("SaveButton rendered");

  return &amp;lt;button onClick={onSave}&amp;gt;Save changes&amp;lt;/button&amp;gt;;
});

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

  const handleSave = useCallback(() =&amp;gt; {
    console.log("Saved");
  }, []);

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;button onClick={() =&amp;gt; setCount(count + 1)}&amp;gt;
        Counter: {count}
      &amp;lt;/button&amp;gt;

      &amp;lt;SaveButton onSave={handleSave} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the callback reference stays stable, so &lt;code&gt;SaveButton&lt;/code&gt; can skip rendering when its props remain unchanged.&lt;/p&gt;

&lt;p&gt;Remember that &lt;code&gt;useCallback&lt;/code&gt; caches a function definition; it doesn't prevent the function from being created during the component's execution. React returns the cached function when its dependencies haven't changed.&lt;/p&gt;

&lt;p&gt;For more details, see the official &lt;a href="https://react.dev/reference/react/useCallback" rel="noopener noreferrer"&gt;useCallback documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Don't optimize every component
&lt;/h3&gt;

&lt;p&gt;It's tempting to wrap every component in &lt;code&gt;memo&lt;/code&gt; and every value in &lt;code&gt;useMemo&lt;/code&gt;. In practice, this can make code harder to read and maintain without improving the user experience.&lt;/p&gt;

&lt;p&gt;Before adding memoization, consider these alternatives:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Keep state close to where it is used&lt;/strong&gt;. If a search field only affects one section, its state usually doesn't need to live at the top of the entire application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid unnecessary Effects&lt;/strong&gt;. An Effect that updates state can create additional render cycles. If a value can be calculated from existing props or state during rendering, you may not need another state variable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use component composition&lt;/strong&gt;. Sometimes moving frequently changing state into a smaller component prevents unrelated parts of the interface from re-rendering.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure expensive calculations&lt;/strong&gt;. Use &lt;code&gt;useMemo&lt;/code&gt; when a calculation is demonstrably expensive or when stable values are needed for an effective memoization boundary.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check your React setup&lt;/strong&gt;. React Compiler can automatically memoize components, values, and functions when appropriately configured. This can reduce the need for manual &lt;code&gt;memo&lt;/code&gt;, &lt;code&gt;useMemo&lt;/code&gt;, and &lt;code&gt;useCallback&lt;/code&gt; in supported applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can learn more in the official &lt;a href="https://react.dev/reference/react/memo" rel="noopener noreferrer"&gt;React memo documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Verify that the optimization worked
&lt;/h3&gt;

&lt;p&gt;After making a change, record the same interaction again using React DevTools Profiler.&lt;/p&gt;

&lt;p&gt;Compare the results before and after the change:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffpvfjvvj1onfuza3zqa3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffpvfjvvj1onfuza3zqa3.png" alt=" " width="711" height="284"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Avoid inventing performance percentages. The improvement depends on your application, the component tree, the data, and the environment.&lt;/p&gt;

&lt;p&gt;Also remember that development-mode measurements can differ from production behavior. React Strict Mode may intentionally invoke rendering logic more than once during development to help reveal bugs. For meaningful performance conclusions, use appropriate profiling tools and repeatable test conditions.&lt;/p&gt;

&lt;p&gt;The goal isn't to achieve the fewest possible renders. It's to remove unnecessary work without making the code more complicated than it needs to be.&lt;/p&gt;

&lt;h2&gt;
  
  
  A practical checklist for debugging React performance
&lt;/h2&gt;

&lt;p&gt;When a React application feels slow, use this sequence:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reproduce the slow interaction consistently.&lt;/li&gt;
&lt;li&gt;Record the interaction with React DevTools Profiler.&lt;/li&gt;
&lt;li&gt;Identify which components consume meaningful rendering time.&lt;/li&gt;
&lt;li&gt;Check whether props, state, or context actually need to change.&lt;/li&gt;
&lt;li&gt;Look for unstable object and function references.&lt;/li&gt;
&lt;li&gt;Consider simpler state placement or component composition.&lt;/li&gt;
&lt;li&gt;Apply memoization only when it addresses the identified problem.&lt;/li&gt;
&lt;li&gt;Profile again and verify both performance and correctness.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Following this process makes React performance debugging more systematic and helps avoid premature optimization.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Unnecessary React re-renders are worth investigating when they cause measurable performance problems, but rendering itself isn't the enemy.&lt;/p&gt;

&lt;p&gt;Start with the React DevTools Profiler, identify the work that matters, and then choose the simplest fix. Stable props, sensible state placement, component composition, and targeted memoization can all help when used for the right reasons.&lt;/p&gt;

&lt;p&gt;Optimizing rendering is just one part of building fast, maintainable React applications. A well-structured component architecture and thoughtful performance decisions also play an important role. If you're exploring these aspects further, learn more about &lt;a href="https://www.encodedots.com/reactjs-development" rel="noopener noreferrer"&gt;ReactJS development&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;The takeaway is simple: measure first, optimize second, and measure again.&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
What's the most common React performance issue you've encountered in a real project: unstable props, expensive calculations, state management, or something else? Share your experience in the comments.&lt;/p&gt;

</description>
      <category>debugging</category>
      <category>react</category>
      <category>reactapplication</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
