[DevTools][Bugfix] Don't hide fragment if it has a key (#25197)
resolves #25187 --- We shouldn't hide fragments that have a key because this is important information that the user might want in the future.
Luna Ruan committed
Sep 7, 2022 at 10:21 UTC
c80e54116e2f9c550472116181a5c66ad97adfbf
1 file changed
+5
-3
packages/react-devtools-shared/src/backend/renderer.js
+5
-3
@@ -468,8 +468,9 @@ export function getInternalReactConstants(
468
return type;
469
case HostPortal:
470
case HostText:
471
- case Fragment:
471
return null;
472
+ case Fragment:
473
+ return 'Fragment';
474
case LazyComponent:
475
// This display name will not be user visible.
476
// Once a Lazy component loads its inner component, React replaces the tag and type.
@@ -981,7 +982,7 @@ export function attach(
982
983
// NOTICE Keep in sync with get*ForFiber methods
984
function shouldFilterFiber(fiber: Fiber): boolean {
984
- const {_debugSource, tag, type} = fiber;
985
+ const {_debugSource, tag, type, key} = fiber;
986
987
switch (tag) {
988
case DehydratedSuspenseComponent:
@@ -993,13 +994,14 @@ export function attach(
994
return true;
995
case HostPortal:
996
case HostText:
996
- case Fragment:
997
case LegacyHiddenComponent:
998
case OffscreenComponent:
999
return true;
1000
case HostRoot:
1001
// It is never valid to filter the root element.
1002
return false;
1003
+ case Fragment:
1004
+ return key === null;
1005
default:
1006
const typeSymbol = getTypeSymbol(type);
1007