Skip to content

react-json-tree crashes on sparse array with 51+ elements #1827

Description

@arcataroger

If you try to show a sparse array with 51 or more elements, JSONTree crashes with Cannot read properties of undefined (reading 'to') from isRange()

This happens any time a sparse array has more than collectionLimit items, which is 50 by default.

let sparseArrayBroken: string[] = [];
sparseArrayBroken[50] = "this causes a crash";
<JSONTree data={sparseArrayBroken} />

Reproduction here: https://codesandbox.io/p/sandbox/ns6q5j

Screenshot.001018.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions