Open
Description
React version: 19.0.0
Devtools version: 6.1.2 (5/7/2025)
Chrome: 136.0.7103.114
Windows 11
Steps To Reproduce
- Go to this codesandbox link https://codesandbox.io/p/sandbox/optimistic-ritchie-forked-yhhjl4
- Specifically open the preview in a new tab at https://yhhjl4.csb.app/ otherwise react devtools won't attach
- Enable "Highlight updates when components render" in react dev tools
- Click the numbered button to cause a rerender
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
If you record via the profiler, the cause is given as "The parent component rendered", but it did not
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)