Modern Full-Stack & React Internals · Chapter 10 of 10 · ~15 min
Project: Virtualized Data Grid
Render 10,000+ rows at 60fps by mounting only the visible viewport window, adding overscan, resetting scroll on filter, and supporting keyboard row navigation.
- Calculate windowed start/end indices with overscan
- Keep DOM node count O(1) regardless of row count
- Reset scrollTop when filters shrink the dataset
- Sync ArrowUp/ArrowDown keyboard focus with scroll position
Project: Virtualized Data Grid: learn it visually
Build a windowed 10,000-row data grid with overscan math, live search filtering, keyboard row navigation, and render performance profiling.
1Windowing Math & Performance Profiling
Mounting thousands of DOM rows stalls layout and paint. Windowing turns a 10,000-row table into ~10–15 positioned nodes.
Wrong idea: Render all 10,000 rows in the DOM and hide off-screen ones with CSS
Even hidden DOM nodes consume layout, style recalculation, and memory, freezing scrolling on large datasets.
Real system: Mount only the visible window + small overscan buffer
Compute startIndex and endIndex from scrollTop / rowHeight so React mounts ~16 rows instead of 10,000.
2Live Project Lab: 10,000-Row Virtualized Grid
Scroll through 10,000 service rows, filter by name or region, adjust Overscan, and watch the mounted DOM count stay tiny.
Window slice [0..7] · Active row #1 · Click grid and press ↑ / ↓
Predict first
With rowHeight = 40, viewportHeight = 200, scrollTop = 400, and overscan = 2, what is the clamped start index?
const start = Math.max(0, Math.floor(400 / 40) - 2);3Bug Hunt · Window Range Math
Fix getVisibleRange so it applies overscan and clamps both ends safely inside [0, totalRows].
🎯 Find and fix the bugs in the code above, then press Run & verify to test your solution.
Need a hint?
Use Math.max(0, Math.floor(scrollTop / rowHeight) - overscan) and Math.min(totalRows, ...).
4Knowledge Check
Why do virtualized grids add a small overscan buffer above and below the viewport?
What should happen to scrollTop when a user types a search filter that reduces 10,000 rows to 5?