Back to Course|Frontend Engineer Interviews: React, System Design & Web Performance Mastery
Lab

Build a Searchable Data Table

25 min
Intermediate
3 Free Attempts

Instructions

Objective

Build a <DataTable> React component that handles large datasets efficiently. This is a common frontend interview take-home challenge.

Requirements

1. Search/Filter

  • Text input that filters rows across all columns
  • Debounced input (300ms) to avoid filtering on every keystroke
  • Show the number of matching results

2. Sorting

  • Click column headers to sort ascending/descending
  • Visual indicator for current sort column and direction
  • Support sorting strings and numbers correctly

3. Pagination

  • Display 20 rows per page
  • Previous/Next page navigation
  • Show current page number and total pages
  • Reset to page 1 when search query changes

4. Performance

  • Must handle 10,000+ rows without noticeable lag
  • Search and sort should feel instant (< 100ms)
  • Minimize unnecessary re-renders

5. Keyboard Navigation

  • Arrow Up/Down to navigate between rows
  • Enter to select a row
  • Escape to clear search

Data Schema

Your component should work with this data shape:

interface User {
  id: number;
  name: string;
  email: string;
  role: string;
  department: string;
  salary: number;
  joinDate: string; // ISO date string
}

interface DataTableProps {
  data: User[];
  columns: {
    key: keyof User;
    label: string;
    sortable?: boolean;
  }[];
}

Example Usage

<DataTable
  data={users}
  columns={[
    { key: 'name', label: 'Name', sortable: true },
    { key: 'email', label: 'Email', sortable: true },
    { key: 'role', label: 'Role', sortable: true },
    { key: 'department', label: 'Department', sortable: true },
    { key: 'salary', label: 'Salary', sortable: true },
  ]}
/>

Hints

  • Use useMemo to memoize filtered and sorted results
  • Use useCallback for event handlers passed to child components
  • Consider useRef for the search input focus management
  • Debounce the search using a custom useDebounce hook
  • For 10K+ rows, consider only rendering visible rows (virtualization) or rely on pagination

Grading Rubric

Search/Filter: Debounced text input filters across all columns with result count displayed20 points
Sorting: Column headers toggle ascending/descending sort with visual indicators, handles both string and number types20 points
Pagination: 20 rows per page, prev/next navigation, page counter, resets on search change20 points
Performance: Uses useMemo for computed data, useCallback for handlers, handles 10K+ rows efficiently20 points
Keyboard Navigation: Arrow keys navigate rows, Enter selects, Escape clears search20 points

Your Solution

This lab requires TypeScript
TSTypeScript(required)
3 free attempts remaining