From 2160aaa534e216a446475003c7f06986708208de Mon Sep 17 00:00:00 2001
From: Roger Tuan <11964962+arcataroger@users.noreply.github.com>
Date: Fri, 7 Feb 2025 12:38:45 -0800
Subject: [PATCH] Update JSONNestedNode.tsx to better handle sparse array
 inputs

---
 packages/react-json-tree/src/JSONNestedNode.tsx | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/packages/react-json-tree/src/JSONNestedNode.tsx b/packages/react-json-tree/src/JSONNestedNode.tsx
index fbc9a47b61..986786fb08 100644
--- a/packages/react-json-tree/src/JSONNestedNode.tsx
+++ b/packages/react-json-tree/src/JSONNestedNode.tsx
@@ -27,7 +27,7 @@ interface Entry {
 }
 
 function isRange(rangeOrEntry: Range | Entry): rangeOrEntry is Range {
-  return (rangeOrEntry as Range).to !== undefined;
+  return (rangeOrEntry as Range)?.to !== undefined;
 }
 
 function renderChildNodes(
@@ -54,6 +54,10 @@ function renderChildNodes(
     from,
     to,
   ).forEach((entry) => {
+    // Don't process null/undefined entries, which can come from sparse arrays
+    if(!entry) {
+      return
+    }
     if (isRange(entry)) {
       childNodes.push(
         <ItemRange