React · Senior · Question 22 of 75
You need to render a list of 100,000 items. What should you do?
- ✓Correct answer: Virtualize: keep only the visible items in the DOM
- 2Wrap each item in
memoand render everything at once - 3Render items in batches of 1000 via
setTimeout
Explanation
The bottleneck is the number of DOM nodes. Virtualization (TanStack Virtual, react-window) renders a window of visible rows and swaps them while scrolling. memo doesn't reduce the DOM, and timer batches only stretch out the same work. Also consider pagination or server-side filtering.