Virtualized List: 10,000 Rows, Twenty Nodes

intermediate
By FrontendAtlas Editorial · Updated Nov 22, 2026
30 min intermediate level
Windowing a long listOverscan and clamping at the edgesScroll events without a polling loopRecycling DOM nodes with keysAccessible virtual lists
Turn a list that renders all 10,000 payment rows into one that renders twenty: a window that follows the scroll position, a jump to any payment, and row nodes that are recycled instead of recreated. The checks scroll the list and count the row nodes the page creates. Concepts: react, performance, lists, dom, accessibility.

Requirements

  • Work in src/App.tsx; treat PAYMENTS, the constants and useRowNodeMeter as given. The starter renders all 10,000 rows and scrolls, while .range and Go are stubs; the four tasks make it fast without changing how the list looks.
  • Task 1: render a window. Keep POOL_SIZE (20) .row elements inside .spacer: VISIBLE_ROWS (10) plus OVERSCAN (5) on each side, starting five rows above the first visible row and clamped so the pool stays inside the list (payments 1–20 at the top, 9,981–10,000 at the bottom). Keep the spacer's height and each row's translateY offset as the starter writes them. Each row keeps role="listitem", data-id, aria-posinset (its payment number), aria-setsize (10000), a .payment text such as Payment 1,001 and its .amount.
  • Task 2: set state in the viewport's scroll handler itself and render the rows in that same update. Do not batch it into requestAnimationFrame or defer the rows: the checks run in a frame that runs no animation frames, and they read the rows as soon as .range changes. The first visible row is the one at the top edge, unless less than half a pixel of it is left; .range counts ten rows from it, Showing 1,001–1,010 of 10,000, with en-US digit grouping and an en dash.
  • Task 3: .go, the form's submit button, scrolls the list so the payment typed in .jump is the first visible row (9,991 and up show the last page), sets the window in the same handler, and says Jumped to payment 4,821. in .jump-status. For anything but digits from 1 up (an empty field, 0, -3, 2.5, 4821.0, 1e3), leave the list where it is and say Enter a whole payment number from 1 to 10,000.
  • Task 4: recycle the row nodes. Scrolling must reuse the same twenty elements, so .row-meter keeps reading 20 row nodes created.
  • Keep the viewport's role="list", aria-label="Payments" and tabIndex={0}, ref={listRef} on .viewport and ref={meterRef} on .row-meter, the viewport at VIEWPORT_HEIGHT, and the viewport's min-width in the workspace's App.css, which lets it scroll in the 1px-wide frame the checks run in.

What the checks look for

The checks find elements by .row, .row-meter, .row[data-id="1"] .payment, .row[data-id="1"] .amount, .row[data-id="20"], .row[data-id="21"], .range, .spacer, .viewport, .row[data-id="7"], .row[data-id="996"], .row[data-id="995"], .row[data-id="1015"], .row[data-id="1016"], .row[data-id="1001"] .payment, .row[data-id="1001"], .row[data-id="1001"] .amount, .row[data-id="1015"] .amount, .row[data-id="1"], .row[data-id="10000"], .row[data-id="9981"], .row[data-id="9980"], .jump, .go, .row[data-id="4821"] .payment, .row[data-id="4821"] .amount, .jump-status, .row[data-id="10000"] .amount. Keep these in your markup.

Expected behavior

  • At the top, payments 1–20 render, .range reads Showing 1–10 of 10,000, and payment 1 shows $357.61.
  • Scrolled to 36,000px, .range reads Showing 1,001–1,010 of 10,000; payments 996 to 1,015 render at translateY(35820px) to translateY(36504px), and payment 1,001 shows $967.61.
  • Scrolled 70px it reads Showing 2–11, and 216px Showing 7–16 with payments 2 to 21. At the bottom (359,640px) it reads Showing 9,991–10,000 with payments 9,981 to 10,000.
  • Jumping to 4821 shows Showing 4,821–4,830 of 10,000, payment 4,821 at $37.81 and Jumped to payment 4,821.; 9995 or 12000 show the last page and Jumped to payment 9,991.; bad input leaves the list where it is and shows the message.
  • Scrolling to the end and back leaves .row-meter at 20 row nodes created.

Implementation notes

  • Everything the list shows can follow from one number: the first visible row.
  • A key decides which DOM node a row lands in.

Solution idea

A virtual list is a function of one number. The scroll handler turns scrollTop into the first visible row, and from that row come a twenty-row pool (five rows of overscan above, ten visible, five below, clamped to the list), the range line and every offset. A spacer as tall as all 10,000 rows gives the browser its scroll range.

Public interview reports

These public, self-reported interview accounts informed this practice version. The exercise is modelled on reported rounds, not copied from them, and the reports are not verified official questions or endorsements.

Reported in a public Binance interview account. Binance frontend interview questions