React Table Component — Design, Implementation, and Performance
Context: You are building a reusable React Table component for a frontend technical screen. The table should accept dynamic column definitions, support client-side sorting and pagination, and be decomposed into clear subcomponents. You must also explain state ownership (local vs. parent) and controlled vs. uncontrolled props. After the base implementation, address extensibility, responsiveness, debugging, and performance.
Requirements
-
Build a reusable Table component with:
-
Client-side pagination and column sorting.
-
Dynamic columns via a
columns
prop, with accessors and optional custom cell renderers.
-
Decomposed UI subcomponents: Table, Header, Body, Row, Cell, Pagination.
-
Justification of state design: what is local, what is controlled by a parent.
Follow-ups
-
Extensibility:
-
How to support plug-in hooks for custom sorting/pagination.
-
How to add a server-side data mode.
-
How to evolve the API without breaking changes.
-
Mobile responsiveness:
-
Support approaches like column priority, stacking, or horizontal scroll.
-
Explain trade-offs of each.
Debug/Performance Task
Given an existing React table implementation, identify and fix:
-
(a) Unnecessary re-renders.
-
(b) Event binding leaks.
-
(c) Misaligned rendering (rows/headers out of sync).
Explain how to detect each (e.g., React DevTools Profiler) and the specific code changes you would make (memoization with React.memo/useMemo, stable callbacks with useCallback/useRef, correct keys, proper effect cleanup).
Bonus
The table feels janky under heavy data. Provide a concrete optimization plan:
-
Measurement and profiling steps.
-
Reducing render work and memoization strategy (dependency hygiene).
-
List virtualization/windowing.
-
Batching/debouncing expensive updates.
-
How React's shallow comparison and reconciliation influence your approach.