[devtools] Prevent incorrect render detection for user components in didFiberRender (#33423) #33434
+14
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes false positive rendering detection in React DevTools Profiler by improving the
didFiberRender
function to accurately detect when user components actually re-render, preventing misleading "The parent component rendered" messages.Problem
Previously, React DevTools would incorrectly mark components as "rendered" even when they didn't actually re-render due to bailouts. This happened because the
didFiberRender
function only checked thePerformedWork
flag, but React can set this flag even during bailout scenarios.Example scenario:
Solution
Enhanced
didFiberRender
function for user components (ClassComponent, FunctionComponent, etc.):This change ensures that:
PerformedWork
flag (performance optimization)Testing
Test Setup:
Used the following test case with independent Count and Greeting components:
Test Results:
✅ Tested and verified with this code
// Before
Screen.Recording.2025-06-04.at.13.17.03.mov
// After
Screen.Recording.2025-06-04.at.13.17.35.mov
Before Fix:
After Fix:
Related
This change specifically targets user components (Function/Class components) and maintains existing behavior for host components, ensuring accurate rendering detection across the React component tree.
Fixes #33423 , #19732