@samitouri / QOS-React / commits / 041754697c

[DevTools] Only show state for ClassComponents (#34091)

The only thing that uses `memoizedState` as a public API is ClassComponents. Everything else uses it as internals. We shouldn't ever show those internals. Before those internals showed up for example on a suspended Suspense boundary: <img width="436" height="370" alt="Screenshot 2025-08-03 at 8 13 37 PM" src="https://github.com/user-attachments/assets/7fe275a7-d5da-421d-a000-523825916630" />

Sebastian Markbåge committed Aug 4, 2025 at 09:26 UTC 041754697c568b8e00fdc1d519a68e3b1e570c38
1 file changed +2 -2
packages/react-devtools-shared/src/backend/fiber/renderer.js
+2 -2
@@ -969,7 +969,6 @@ export function attach(
969 } = getInternalReactConstants(version);
970 const {
971 ActivityComponent,
972 - CacheComponent,
972 ClassComponent,
973 ContextConsumer,
974 DehydratedSuspenseComponent,
@@ -4618,7 +4617,8 @@ export function attach(
4617
4618 // TODO Show custom UI for Cache like we do for Suspense
4619 // For now, just hide state data entirely since it's not meant to be inspected.
4621 - const showState = !usesHooks && tag !== CacheComponent;
4620 + const showState =
4621 + tag === ClassComponent || tag === IncompleteClassComponent;
4622
4623 const typeSymbol = getTypeSymbol(type);
4624