Skip to content

Commit

Permalink
Code review feedback / consolidation
Browse files Browse the repository at this point in the history
  • Loading branch information
robpaveza committed Jan 22, 2021
1 parent 0b4bf08 commit 2750f52
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions packages/devtools-network-console/src/ui/JSONView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,45 +31,43 @@ function* produceObjectChildren(value: object, depth: number): IterableIterator<
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const childValue = (value as Record<string, unknown>)[key];
const itemProps = {
key,
className: 'json-tree-view-item-can-wrap',
titleContent: (<Property keyKind="string" name={key} value={childValue} />),
'aria-level': depth,
};

if (typeof childValue === 'object' && childValue !== null && Object.keys(childValue).length > 0) {
yield <TreeViewItem
key={key}
className="json-tree-view-item-can-wrap"
titleContent={<Property keyKind="string" name={key} value={childValue} />}
{...itemProps}
children={produceChildren(childValue, depth + 1)}
aria-level={depth}
/>;
}
else {
yield <TreeViewItem
key={key}
className="json-tree-view-item-can-wrap"
titleContent={<Property keyKind="string" name={key} value={childValue} />}
aria-level={depth}
/>;
yield <TreeViewItem {...itemProps} />;
}
}
}

function* produceArrayChildren(value: Array<unknown>, depth: number): IterableIterator<React.ReactNode> {
for (let i = 0; i < value.length; i++) {
const childValue = value[i];
const itemProps = {
key: i,
className: 'json-tree-view-item-can-wrap',
titleContent: (<Property keyKind="number" name={i} value={childValue} />),
'aria-level': depth,
};

if (typeof childValue === 'object' && childValue !== null && Object.keys(childValue).length > 0) {
yield <TreeViewItem
key={i}
className="json-tree-view-item-can-wrap"
titleContent={<Property keyKind="number" name={i} value={childValue} />}
{...itemProps}
children={produceChildren(childValue, depth + 1)}
aria-level={depth}
/>;
}
else {
yield <TreeViewItem
key={i}
className="json-tree-view-item-can-wrap"
titleContent={<Property keyKind="number" name={i} value={childValue} />}
aria-level={depth}
/>;
yield <TreeViewItem {...itemProps} />;
}
}
}
Expand Down

0 comments on commit 2750f52

Please sign in to comment.