+
Grid Virtualizer Example
+
+ Virtualizing a {TOTAL_ROWS.toLocaleString()} × {TOTAL_COLUMNS} grid (
+ {(TOTAL_ROWS * TOTAL_COLUMNS).toLocaleString()} cells)
+
+
+ Scroll both horizontally and vertically - only visible cells are rendered!
+
+
+
+
+
+
+
+
+
+
+
{
+ flushSync(() => {
+ virtualizer.handleScroll(e)
+ })
+ }}
+ {...virtualizer.getContainerAriaAttrs()}
+ style={{
+ height: "500px",
+ width: "100%",
+ maxWidth: "900px",
+ ...virtualizer.getContainerStyle(),
+ border: "1px solid #ccc",
+ borderRadius: "8px",
+ marginTop: "16px",
+ }}
+ >
+ {/* Total scrollable area */}
+
+ {/* Render only visible cells */}
+ {virtualCells.map((cell) => {
+ const data = generateCellData(cell.row, cell.column)
+ const style = virtualizer.getCellStyle(cell)
+
+ return (
+
+ {data.value}
+
+ )
+ })}
+
+
+
+ {/* Stats */}
+
+
+ Grid Size: {TOTAL_ROWS.toLocaleString()} rows × {TOTAL_COLUMNS} cols
+
+
+ Total Cells: {(TOTAL_ROWS * TOTAL_COLUMNS).toLocaleString()}
+
+
+ Rendered Cells: {virtualCells.length}
+
+
+ Visible Rows: {range.startRow} - {range.endRow} ({visibleRows} rows)
+
+
+ Visible Cols: {range.startColumn} - {range.endColumn} ({visibleCols} cols)
+
+
+ Total Size: {totalWidth}px × {totalHeight}px
+
+
+ {virtualCells.length < 500 ? (
+
+ ✅ Virtualization working! Only {virtualCells.length} of {(TOTAL_ROWS * TOTAL_COLUMNS).toLocaleString()}{" "}
+ cells rendered
+
+ ) : (
+ ⚠️ Many cells rendered
+ )}
+
+
+
+