Renders the body of a `DataTable` component, handling three states: loading skeleton, empty state, and populated rows — with optional row padding to maintain stable table height. ## Key Components ### `DataTableBody` The primary export. Consumes `DataTableContext` via `useDataTableContext` and conditionally renders one of three views: - **Loading:** Displays `DataTableSkeleton` when `loading={true}` and rows are empty - **Empty:** Renders `DataTableEmpty` using `emptyState` props (or falls back to deprecated `emptyMessage`) - **Rows:** Maps each row to a `DataTableRow`, with optional sub-row expansion via `renderSubRow` ### `DataTableBodyProps` Full interface for configuring body behavior including: | Prop | Purpose | |---|---| | `loading` | Triggers skeleton display when data is empty | | `emptyState` | `NoDataProps` for rich empty state UI | | `emptyMessage` | ⚠️ Deprecated — use `emptyState` instead | | `skeletonRows` | Number of skeleton rows (default: `10`) | | `rowClassName` | Static string or per-row function | | `onRowClick` | Row click handler (memoize with `useCallback`) | | `rowHref` | Converts rows to Next.js links (ignored if `onRowClick` set) | | `minRows` | Pads with invisible rows to stabilize table height | | `renderSubRow` | Returns expandable content rendered below a row | ## Usage Example ```typescript import { DataTable } from './data-table' import { DataTableBody } from './data-table-body' import { DataTableColumn } from './data-table-column' import { useCallback } from 'react' function UserTable({ users, isLoading }) { const handleRowClick = useCallback((user) => { router.push(`/users/${user.id}`) }, []) const rowClassName = useCallback( (user, index) => (index % 2 === 0 ? 'bg-muted/30' : ''), [] ) return ( loading={isLoading} skeletonRows={8} minRows={8} compact onRowClick={handleRowClick} rowClassName={rowClassName} emptyState={{ title: 'No users found', description: 'Try adjusting your filters.' }} renderSubRow={(user) => user.notes ? : null} /> ) } ``` > **Performance note:** Always memoize `onRowClick`, `rowHref`, and function-form `rowClassName` with `useCallback` to preserve `React.memo` optimizations on `DataTableRow`.