Skip to content

Bug: profiler incorrectly reports 'The parent component rendered' #33423

Open
@michaelboyles

Description

@michaelboyles

React version: 19.0.0

Devtools version: 6.1.2 (5/7/2025)

Chrome: 136.0.7103.114

Windows 11

Steps To Reproduce

  1. Go to this codesandbox link https://codesandbox.io/p/sandbox/optimistic-ritchie-forked-yhhjl4
  2. Specifically open the preview in a new tab at https://yhhjl4.csb.app/ otherwise react devtools won't attach
  3. Enable "Highlight updates when components render" in react dev tools
  4. Click the numbered button to cause a rerender
Full code (click to show)
import { useState, useRef } from "react";

const Count = () => {
  const [count, setCount] = useState(0);
  return <button onClick={() => setCount((c) => c + 1)}>{count}</button>;
};

export function Greeting() {
  const renderCount = useRef(0);
  renderCount.current++;
  console.log("Greeting rendered");
  return <span>Hello World! (rendered {renderCount.current} times)</span>;
}

export default function App() {
  return (
    <div>
      <Count />
      <div>
        <Greeting />
      </div>
    </div>
  );
}

The current behavior

The Greeting component will flash as being rerendered even though it isn't

Image

If you record via the profiler, the cause is given as "The parent component rendered", but it did not

Image

The expected behavior

It neither flashes, nor is reported in the profiler flamegraph after being recorded. It didn't rerender.


Here's some variants I tested:

✅= Greeting correctly reported as not rerendering
❌ = Greeting incorrectly reported as rerendering

//✅ Same level
<Count />
<Greeting />

//✅ Greeting above
<div>
    <Greeting />
    <div><Count /></div>
</div>

// ❌ Greeting below in div
<Count />
<div>
    <Greeting />
</div>

// ❌ Greeting below in empty fragment 
<Count />
<>
    <Greeting />
</>

This is the same as #19732. Reopening here as per the directions in #19732 (comment)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions