Rendering strategies and React · mid
Long lists: virtualisation, pagination and content-visibility
Rendering thousands of rows creates a huge DOM that slows every frame, so you render only the visible window plus a small overscan (virtualisation), or paginate, or let the browser skip off-screen rendering with content-visibility.
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
- Virtualisation: compute which rows are visible from scrollTop and row height, render only those plus an overscan buffer, and use spacer height so the scrollbar is correct.
- Variable row heights: estimate first, measure rows after render, cache the measurements, and correct the offsets.
- Libraries: TanStack Virtual, react-window, react-virtuoso; on React Native, FlatList/FlashList do the same job.
- Costs of virtualisation: browser find-in-page cannot see off-screen rows, screen readers need aria-rowcount / aria-rowindex (or aria-setsize/posinset), and focus can be lost when a row unmounts.
- content-visibility: auto is a lighter alternative for long documents: the DOM stays, but the browser skips layout and paint for off-screen sections. Set contain-intrinsic-size.
- Do not virtualise small lists (under a few hundred simple rows); pagination or 'load more' can be simpler and more accessible.
The red pen
Common traps: mistake → fix
Mistake: "Virtualise every list"
Fix: for 50 items it adds complexity and breaks find-in-page for no gain.
Mistake: "Use the array index as key in a virtual list"
Fix: rows get the wrong state when items are inserted or reordered.
Mistake: "Virtualisation is only a scrolling trick"
Fix: it also cuts memory, style and layout work, which helps INP.
Easy to hard
Questions interviewers ask, easy to hard
- How does windowing (virtualisation) work?
- How do you handle variable row heights?
- What breaks for accessibility and how do you fix it?
- Virtualisation vs pagination vs content-visibility: when would you pick each?
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.