Virtualized List

HardPerformanceRenderingReact30 mins

by Pratik Rai

Read the full write-up

Ten thousand rows, and only the ones on screen in the DOM.

The scrollbar has to behave as though every row were rendered — the right length, the right position — while the number of elements stays roughly constant however far down you scroll.

Requirements

  1. Only the rows in view (plus a small buffer) exist in the DOM.

  2. The scrollbar reflects the full list: scrolling to the bottom reaches row 10,000.

  3. Rows appear at the correct position, so the content does not drift as you scroll.

  4. Row height is fixed at ROW_HEIGHT, which is what makes the maths possible.

  5. Show how many rows are currently in the DOM, so the saving is visible.

Notes

  • This is windowing, not infinite scroll — the data is all available, the problem is the DOM.

  • Scroll fast and watch for blank space at the edges; that is what the buffer is for.

Hints

Loading editor…