[DevTools] Hide props section if it is null (#30696)
We use null as a marker that we don't know what the props are as opposed to knowing that they're empty.
Sebastian Markbåge committed
Aug 14, 2024 at 15:48 UTC
fca5d655d78917400a2722287351c20938166669
1 file changed
+6
-3
packages/react-devtools-shared/src/devtools/views/Components/InspectedElementPropsTree.js
+6
-3
@@ -54,11 +54,14 @@ export default function InspectedElementPropsTree({
54
type === ElementTypeClass || canEditFunctionPropsRenamePaths;
55
56
const entries = props != null ? Object.entries(props) : null;
57
- if (entries !== null) {
58
- entries.sort(alphaSortEntries);
57
+ if (entries === null) {
58
+ // Skip the section for null props.
59
+ return null;
60
}
61
61
- const isEmpty = entries === null || entries.length === 0;
62
+ entries.sort(alphaSortEntries);
63
+
64
+ const isEmpty = entries.length === 0;
65
66
const handleCopy = () => copy(serializeDataForCopy(((props: any): Object)));
67