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

Open
#1,827 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
frontend

Research direction

Start in packages/react-json-tree/src/JSONNestedNode.tsx at isRange(), then read the collectionLimit default in packages/react-json-tree/src/index.tsx. Reproduce the crash with the sparse-array example or the linked CodeSandbox. Done means JSONTree renders a sparse array with more than 50 elements without throwing.

Written by the indexing model from the issue text.

Description

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

https://github.com/user-attachments/assets/9f7bce8f-33ea-4aeb-9db6-4b6ad8fa2f7c

Dominant language
TypeScript
Stars
14.4k
Forks
1.2k
Avg merge
1d 6h
Merged PRs (30d)
20

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from reduxjs/redux-devtools

All issues in reduxjs/redux-devtools

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.