FrontendInterviews.dev

Loading problem…

123. Data Table - Virtual Scrolling

Hard•
Acceptance: 44.00%
•
🔓3/3 Pro unlocks today

This problem builds on data-table-pagination. Complete that first, then load your solution to continue.

Build a production-ready Data Table component that extends the base Data Table with virtual scrolling functionality. This builds on top of the sorting feature from the base Data Table.

Requirements

1. Virtual Scrolling

  • Render only visible rows in viewport
  • Calculate row heights dynamically
  • Smooth scrolling performance
  • Handle large datasets efficiently (1000+ rows)
  • Maintain scroll position

2. Data Structure

interface Column {
  key: string;
  label: string;
  sortable?: boolean;
}

interface DataTableProps {
  data: Record<string, any>[];
  columns: Column[];
  rowHeight?: number;
  overscan?: number;
}

Example Usage

<DataTable 
  data={data} 
  columns={columns}
  rowHeight={40}
  overscan={5}
/>

Constraints

  • Implement virtual scrolling for large datasets (1000+ rows)
  • Maintain sorting functionality from base Data Table
  • Calculate visible range based on scroll position