Add Virtualization Support for Large JSON Objects
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- react, typescript
- 领域
- frontend, performance
调研方向
Start at the JsonView component entry point and reproduce the 5,000-key example with the listed React and package versions while recording initial render and scrolling performance. Compare the proposed virtualization approaches, then define completion against the expected behavior: only visible nodes render, scrolling remains smooth, memory does not grow with object size, and initial rendering is fast.
由索引模型根据 Issue 内容生成。
描述
Problem Description
When rendering large JSON objects (e.g., 1000+ keys or deeply nested structures), the component causes significant performance degradation, making the page laggy and unresponsive. All DOM nodes are rendered immediately, even those not visible in the viewport.
Current Behavior
- All JSON nodes are rendered to the DOM immediately
- Large objects (1000+ keys) cause noticeable UI lag
- Scrolling becomes janky with large datasets
- Memory usage increases linearly with object size
- Browser can become unresponsive during initial render
Expected Behavior
- Only visible nodes should be rendered (windowing/virtualization)
- Smooth scrolling regardless of JSON size
- Constant memory usage regardless of object size
- Fast initial render time
Minimal Reproduction
import JsonView from '@uiw/react-json-view';
import { useState, useEffect } from 'react';
function App() {
const [largeObject, setLargeObject] = useState({});
useEffect(() => {
// Generate a large object with 5000 keys
const obj: Record<string, any> = {};
for (let i = 0; i < 5000; i++) {
obj[`key_${i}`] = {
id: i,
name: `Item ${i}`,
description: `Description for item ${i}`,
metadata: {
created: new Date().toISOString(),
modified: new Date().toISOString(),
tags: ['tag1', 'tag2', 'tag3'],
nested: {
level1: {
level2: {
level3: {
data: `Deep nested data ${i}`
}
}
}
}
}
};
}
setLargeObject(obj);
}, []);
return (
<div style={{ height: '100vh', padding: '20px' }}>
<h1>Large JSON Performance Test</h1>
<p>Object size: {Object.keys(largeObject).length} keys</p>
<div style={{ height: 'calc(100vh - 100px)', overflow: 'auto', border: '1px solid #ccc' }}>
<JsonView
value={largeObject}
displayDataTypes={false}
displayObjectSize={false}
collapsed={1} // Collapse by default
/>
</div>
</div>
);
}
export default App;
Steps to Reproduce
- Create a new React app with
@uiw/[email protected] - Use the above code example
- Open browser DevTools Performance tab
- Start recording and wait for component to render
- Try scrolling through the JSON view
Proposed Solution
Implement virtualization using one of these approaches:
Option 1: React Window / React Virtual
Use a proven virtualization library to render only visible nodes:
import { FixedSizeList } from 'react-window';
// Pseudo-code example
<FixedSizeList
height={600}
itemCount={visibleNodes.length}
itemSize={24}
width="100%"
>
{({ index, style }) => (
<div style={style}>
<JsonNode node={visibleNodes[index]} />
</div>
)}
</FixedSizeList>
Option 2: Custom Virtualization
Implement a custom windowing solution that:
- Tracks scroll position
- Calculates visible range of nodes
- Renders only nodes within viewport + buffer
- Maintains proper scroll height with padding elements
Benefits
- ✅ Handles objects with 10,000+ keys smoothly
- ✅ Constant memory usage regardless of JSON size
- ✅ 60 FPS scrolling performance
- ✅ Fast initial render (< 100ms)
- ✅ Better user experience for data-heavy applications
Environment
- Package version:
@uiw/[email protected] - React version:
^18.3.1 - Browser: Chrome 131, Firefox 133, Safari 18
- OS: macOS, Windows, Linux
Additional Context
Many similar libraries have implemented virtualization:
- react-json-tree - Uses react-virtualized
- jsoneditor - Custom virtualization
- Monaco Editor - Built-in virtualization for JSON mode
Workarounds Currently Used
- Pagination: Breaking large objects into smaller chunks (poor UX)
- Lazy loading on expand: Loading children only when expanded (complex state management)
- Limiting display: Only showing first N items (data loss)
- External viewers: Opening in separate tools (context switching)
None of these are ideal solutions compared to built-in virtualization.
Would love to see virtualization support in this library! Happy to contribute to implementation if you'd like to provide guidance on the preferred approach. 🚀
- 主要语言
- TypeScript
- 星标
- 420
- 派生
- 24
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
uiwjs/react-json-view 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
uiwjs/react-json-view#92 · 3 条评论 ·
-
难度 5/5 一周以上 新手友好度 20/100
uiwjs/react-json-view#93 ·
-
Named export未关闭
难度 2/5 1-3 小时 新手友好度 35/100
uiwjs/react-json-view#90 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 52/100
uiwjs/react-json-view#89 ·
-
难度 2/5 1-3 小时 新手友好度 45/100
uiwjs/react-json-view#88 · 1 个 reaction ·
查看 uiwjs/react-json-view 的全部 Issue
相似的 Issue
-
bug via-triage
难度 2/5 1-3 小时 新手友好度 78/100
pingdotgg/t3code#14452 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
solana-foundation/program-examples#747 · 1 条评论 ·
维护者通常 9 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
remotion-dev/remotion#11847 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
openwatersio/slackwater#355 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
melgarafael/DeskcommCRM#1998 · 3 条评论 ·
维护者通常 1 天内回复