Migration
- From 1.x to 2.0 of this package (TanStack Table 9).
- From
@ackplus/react-tanstack-data-table, the deprecated predecessor.
From 1.x to 2.0
2.0 moves the grid to TanStack Table 9. The grid's own API does not change: the same props, the same
apiRef, the same column options, and saved layouts, saved views and persisted state carry over. What
changes is the setup around it, and anything you do with the raw TanStack table.
Requirements
| 1.x | 2.0 | |
|---|---|---|
| TanStack Table | 8, bundled with the grid | 9, a peer dependency you install |
| MUI | 5, 6, 7, 9 | 7, 9 |
| Module format | ESM + CommonJS | ESM only |
| Node | 18+ | 20+ |
| React | 18, 19 | 18, 19 |
npm install @ackplus/mui-tanstack-data-grid@2 @tanstack/react-table@9
On MUI 5 or 6, stay on 1.x (@ackplus/mui-tanstack-data-grid@1) or upgrade MUI first. MUI 5 and 6 have
no exports map, so Node's ESM loader can't load them from an ESM-only package.
ESM only. Bundlers (Vite, webpack, Next.js, Rollup, esbuild) need no change. Node 20.19+ and 22.12+
can still require() the package. A test runner that loads CommonJS only (Jest without ESM support)
needs to transform the package or switch to its ESM mode.
Code changes
Most apps need none. Check these:
-
Import table types from the grid. TanStack 9 types take a "features" type first (
Row<TFeatures, TData>). The grid exports versions bound to its own features, with the 1.x shapes:// ✅ the grid's ColumnDef includes its column options (type, align, valueGetter, …)import type { ColumnDef, Row } from '@ackplus/mui-tanstack-data-grid';const columns: ColumnDef<User>[] = [/* … */];ColumnDeffrom@tanstack/react-tableitself no longer carries the grid's options. -
TanStack's
aggregationFntakes a definition. The grid's ownaggregationoption is unchanged. If you set TanStack'saggregationFnto a function, wrap it:- aggregationFn: (columnId, leafRows) => leafRows.length,+ aggregationFn: { aggregate: (context) => context.rows.length }, -
The raw table is TanStack 9.
apiRef.current.table.getTable()returns a v9 table. The grid addsgetState()back (with column pinning asleft/right), but TanStack's own APIs follow v9: for examplegetPaginatedRowModel()(wasgetPaginationRowModel()), andcolumn.getIsPinned()returns'start'/'end'. See TanStack's migration guide. -
Column pinning stays
left/rightin the grid:initialState.columnPinning,onColumnPinningChange,api.columnPinning.pinColumnLeft()and saved layouts. TanStack 9 calls the sidesstart/end; the grid maps between them. -
Removed: the deprecated locale key
columnMenuAutosize(autosize left the column menu in 1.13; double-click a resize handle instead).VisibilityStateis nowColumnVisibilityState(the old name still works).
From @ackplus/react-tanstack-data-table
This package is the successor to the deprecated @ackplus/react-tanstack-data-table. Same mental
model and the same apiRef, but the grid now renders as <div> + CSS Grid (not an HTML <table>),
theming is MUI-native + tokens, and some props are renamed. Old names keep working as deprecated
aliases, so you can migrate gradually.
1. Install
npm install @ackplus/mui-tanstack-data-grid @tanstack/react-table@9
npm uninstall @ackplus/react-tanstack-data-table
- import { DataTable } from '@ackplus/react-tanstack-data-table';
+ import { DataTable } from '@ackplus/mui-tanstack-data-grid';
2. Prop renames
The v1 names still work (each maps to its new name, and the new name wins when both are set), but they're deprecated: your editor shows them struck through. Rename them when you can.
| v1 | v2 | Notes |
|---|---|---|
tableSize="small" | density="compact" | small→compact, medium→standard |
enableTableSizeControl | enableDensitySelector | |
enableStripes | striped | |
enableHover | hover | |
enableStickyHeaderOrFooter | stickyHeader | + stickyFooter |
enableColumnDragging | enableColumnReordering | |
onColumnDragEnd | onColumnOrderChange | same payload |
enableExpanding | enableRowExpansion | |
renderSubComponent | renderDetailPanel | same signature |
bulkActions | renderBulkActions | same signature |
totalRow | rowCount | server total |
estimateRowHeight | estimatedRowHeight | |
emptyMessage | noRowsMessage | |
onColumnFiltersChange | onColumnFilterChange | same signature |
tableProps | slotProps.grid | typed, no more any |
tableContainerProps | slotProps.scroller | typed |
3. Behaviour changes
- The grid renders as
<div>s with ARIA roles, not a<table>. CSS that targetedtable/td/.MuiTable-*should move to tokens,MuiTanstackDataGridstyle overrides, orslotProps. - Column
minSize/maxSizeare now respected, and resizing no longer redistributes neighbouring columns. - Density names changed (
small/medium→compact/standard/comfortable). - Excel export lazy-loads
xlsxon first use; the API is unchanged.
4. Imperative handle: ref → apiRef
The imperative API (its namespaces and method names) is unchanged — but how you obtain it changed.
In v1, <DataTable> was a forwardRef component, so you read the handle off a React ref. In v2,
<DataTable> is a plain function component that does not accept a ref; it exposes the handle
through a dedicated apiRef prop instead.
- const ref = useRef<DataTableApi<Row>>(null);
- <DataTable ref={ref} columns={columns} data={rows} />;
+ const apiRef = useRef<DataTableApi<Row> | null>(null);
+ <DataTable apiRef={apiRef} columns={columns} data={rows} />;
Once wired, apiRef.current gives you the same API as before (apiRef.current?.selection.selectAll(),
apiRef.current?.export.exportCSV(), etc.).
v1's stateKey lived on the example app's DataGrid wrapper. Since 1.5.0 stateKey is a first-class
<DataTable> prop — pass it directly and the grid persists view state for you (see
State persistence). For v1's defaultHiddenColumns, map the hidden names
into initialState.columnVisibility.