Search, lists and data · senior
Virtualised list (windowing) by hand
A virtualised list renders only the rows inside the viewport plus a small overscan, inside a container as tall as the whole list, computing the visible range from scrollTop—with simple division for fixed heights, and prefix sums plus binary search for measured variable heights.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Structure: a scroll container (fixed height, overflow: auto) → an inner spacer with the total height → visible rows positioned with transform: translateY(offset) or absolute top.
- Fixed height: start = floor(scrollTop / rowHeight) − overscan, end = ceil((scrollTop + viewportHeight) / rowHeight) + overscan, clamped.
- Variable height: measure rendered rows (ResizeObserver), cache heights by id (estimate unmeasured ones), build prefix-sum offsets, binary-search the first row whose bottom passes scrollTop.
- Scroll handling: read scrollTop in a passive scroll listener and update state at most once per animation frame.
- Keys stay stable ids; keep row components memoised; overscan 3–10 rows to avoid blank flashes on fast scroll.
- Trade-offs: browser find-in-page, anchor links and screen readers only see rendered rows; add aria-rowcount/aria-rowindex for grids; for static content content-visibility: auto (Baseline 2024) is a lighter alternative.
- In rounds you usually can't use react-window; say you would in production (react-window, TanStack Virtual, or FlashList in React Native).
The red pen
Common traps: mistake → fix
Mistake: Forget the spacer
Fix: the scrollbar is tiny and you can't scroll to the end.
Mistake: Use array indexes as keys while the list is filtered
Fix: wrong rows keep state.
Mistake: Recompute everything in the scroll event without rAF
Fix: jank.
Mistake: Assume all rows are the same height when they aren't
Fix: rows overlap or gaps appear.
Easy to hard
Questions interviewers ask, easy to hard
- Render 100,000 rows smoothly.
- Explain the maths for the visible range.
- Rows have different heights. What changes?
- What do you lose by virtualising?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.