Skip to content

Commit 7f3f480

Browse files
committed
Fix "Invalid array length" error
If an object has more keys than `groupArraysAfterLength`, then it will be rendered as an Array due to the changes in mac-s-g#336 Fix this logic so only arrays are rendered as arrays. Fixes mac-s-g#340
1 parent 34c3994 commit 7f3f480

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/js/components/JsonViewer.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ export default class extends React.PureComponent {
88
const namespace = [props.name];
99
let ObjectComponent = JsonObject;
1010

11-
const size = Array.isArray(props.src)
12-
? props.src.length
13-
: Object.keys(props.src).length;
1411
if (
12+
Array.isArray(props.src) &&
1513
props.groupArraysAfterLength &&
16-
size > props.groupArraysAfterLength
14+
props.src.length > props.groupArraysAfterLength
1715
) {
1816
ObjectComponent = ArrayGroup;
1917
}

0 commit comments

Comments
 (0)