Community JavaScript Snippet

Windowing a 10k Row List Without react-window

We had a 10k row list freezing scroll. react-window worked but was overkill for our shape. Here is the 60 line virtualizer we shipped instead.

Windowing a 10k Row List Without react-window

We had a 10k row list freezing scroll. react-window worked but was overkill for our shape. Here is the 60 line virtualizer we shipped instead.

JavaScript
Frontend
3 snippets
react
performance-optimization
references
norapetrov

By @norapetrov

February 10, 2026

·

Updated May 20, 2026

765 views

15

4.3 (10)

I keep the math out of the hook because every windowing bug I have ever shipped lived in this function, and a pure function is the only place I can test those bugs without spinning up a renderer. Three clamps matter. First, Math.max(0, scrollTop) because iOS rubber-band scrolling reports negative values on overscroll. Second, Math.max(1, itemHeight) because a zero-height row would divide by zero on the first pass. Third, Math.min(totalCount - 1, ...) so the end index never points past the array. The overscan buffer is what hides the white-flash when you scroll fast: render a few rows above and below the viewport so the next ones are already in the DOM.