Do not put fifty thousand rows in the DOM. Virtualize so only the visible window plus a small overscan is rendered, keep row height predictable or measure it, and move sorting and filtering out of render into memoized derived data or the server. Paginate or stream the data itself, keep the edited row's state local so a keystroke does not re render the table, and test with a throttled CPU.
Why interviewers ask this
This checks whether you understand where the cost actually is: DOM node count, layout, and re rendering the whole list on every keystroke. The interviewer wants to see you separate the data problem from the rendering problem and consider accessibility and keyboard behavior, which naive virtualization breaks. Reaching straight for a maintained library is a fine answer if you can explain what it does for you.
How to structure your answer
- Say the DOM node count is the constraint and virtualize.
- Split the data concern from the rendering concern.
- Keep edit state local so typing does not re render everything.
- Call out the accessibility and search tradeoffs virtualization creates.
Example answer
The first thing I say is that fifty thousand rows should never be in the DOM at once, because layout and memory scale with node count no matter how fast my framework is. So I virtualize: render the rows in the viewport plus a small overscan, absolutely position them inside a spacer with the total height, and recycle as the user scrolls. Then I treat the data as a separate problem. Sorting and filtering fifty thousand records on every keystroke will block the main thread, so either the server does it and I request a page, or I memoize the derived array so it only recomputes when the sort key really changes. For inline editing I keep the draft value in the row's own state and only lift it on commit, otherwise every character re renders the table. The parts people forget are accessibility and find in page: screen readers and browser search only see rendered rows, so I set the row count attributes explicitly and provide a real search box rather than relying on the browser's.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- How do you handle rows with variable heights?
- What breaks about keyboard navigation in a virtualized table?
- When would you push sorting to the server instead?
Related frontend developer questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions