@tanstack/react-table 9.0.0-alpha.9 → 9.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +127 -0
  2. package/dist/FlexRender.cjs +61 -0
  3. package/dist/FlexRender.cjs.map +1 -0
  4. package/dist/FlexRender.d.cts +51 -0
  5. package/dist/FlexRender.d.ts +51 -0
  6. package/dist/FlexRender.js +58 -0
  7. package/dist/FlexRender.js.map +1 -0
  8. package/dist/Subscribe.cjs +13 -0
  9. package/dist/Subscribe.cjs.map +1 -0
  10. package/dist/Subscribe.d.cts +101 -0
  11. package/dist/Subscribe.d.ts +101 -0
  12. package/dist/Subscribe.js +13 -0
  13. package/dist/Subscribe.js.map +1 -0
  14. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  15. package/dist/createTableHook.cjs +313 -0
  16. package/dist/createTableHook.cjs.map +1 -0
  17. package/dist/createTableHook.d.cts +358 -0
  18. package/dist/createTableHook.d.ts +358 -0
  19. package/dist/createTableHook.js +311 -0
  20. package/dist/createTableHook.js.map +1 -0
  21. package/dist/flex-render.cjs +5 -0
  22. package/dist/flex-render.d.cts +2 -0
  23. package/dist/flex-render.d.ts +2 -0
  24. package/dist/flex-render.js +3 -0
  25. package/dist/index.cjs +18 -0
  26. package/dist/index.d.cts +6 -0
  27. package/dist/index.d.ts +6 -0
  28. package/dist/index.js +8 -0
  29. package/dist/legacy.cjs +14 -0
  30. package/dist/legacy.d.cts +2 -0
  31. package/dist/legacy.d.ts +2 -0
  32. package/dist/legacy.js +3 -0
  33. package/dist/reactivity.cjs +34 -0
  34. package/dist/reactivity.cjs.map +1 -0
  35. package/dist/reactivity.js +34 -0
  36. package/dist/reactivity.js.map +1 -0
  37. package/dist/static-functions.cjs +9 -0
  38. package/dist/static-functions.d.cts +1 -0
  39. package/dist/static-functions.d.ts +1 -0
  40. package/dist/static-functions.js +3 -0
  41. package/dist/useLegacyTable.cjs +191 -0
  42. package/dist/useLegacyTable.cjs.map +1 -0
  43. package/dist/useLegacyTable.d.cts +233 -0
  44. package/dist/useLegacyTable.d.ts +233 -0
  45. package/dist/useLegacyTable.js +181 -0
  46. package/dist/useLegacyTable.js.map +1 -0
  47. package/dist/useTable.cjs +72 -0
  48. package/dist/useTable.cjs.map +1 -0
  49. package/dist/useTable.d.cts +122 -0
  50. package/dist/useTable.d.ts +122 -0
  51. package/dist/useTable.js +72 -0
  52. package/dist/useTable.js.map +1 -0
  53. package/package.json +41 -22
  54. package/skills/react/client-to-server/SKILL.md +377 -0
  55. package/skills/react/compose-with-tanstack-form/SKILL.md +363 -0
  56. package/skills/react/compose-with-tanstack-pacer/SKILL.md +287 -0
  57. package/skills/react/compose-with-tanstack-query/SKILL.md +467 -0
  58. package/skills/react/compose-with-tanstack-store/SKILL.md +347 -0
  59. package/skills/react/compose-with-tanstack-virtual/SKILL.md +388 -0
  60. package/skills/react/compose-with-tanstack-virtual/references/column-virtualization-and-infinite-scroll.md +136 -0
  61. package/skills/react/getting-started/SKILL.md +388 -0
  62. package/skills/react/migrate-v8-to-v9/SKILL.md +488 -0
  63. package/skills/react/production-readiness/SKILL.md +341 -0
  64. package/skills/react/react-subscribe-compiler-compat/SKILL.md +269 -0
  65. package/skills/react/table-state/SKILL.md +432 -0
  66. package/src/FlexRender.tsx +136 -0
  67. package/src/Subscribe.ts +153 -0
  68. package/src/createTableHook.tsx +1121 -0
  69. package/src/flex-render.ts +1 -0
  70. package/src/index.ts +6 -0
  71. package/src/legacy.ts +3 -0
  72. package/src/reactivity.ts +41 -0
  73. package/src/static-functions.ts +1 -0
  74. package/src/useLegacyTable.ts +487 -0
  75. package/src/useTable.ts +191 -0
  76. package/dist/cjs/index.cjs +0 -77
  77. package/dist/cjs/index.cjs.map +0 -1
  78. package/dist/cjs/index.d.cts +0 -9
  79. package/dist/esm/index.d.ts +0 -9
  80. package/dist/esm/index.js +0 -55
  81. package/dist/esm/index.js.map +0 -1
  82. package/src/index.tsx +0 -92
@@ -0,0 +1,488 @@
1
+ ---
2
+ name: react/migrate-v8-to-v9
3
+ description: >
4
+ Mechanical breaking-change migration from `@tanstack/react-table` v8 to v9.
5
+ Every v8-shaped option, type, or method an agent will reproduce from muscle
6
+ memory has a v9 equivalent enumerated below: `useReactTable` → `useTable`,
7
+ root `get*RowModel` options → `rowModels` with factory + *Fns parameter,
8
+ `createColumnHelper<TData>` → `createColumnHelper<typeof features, TData>`,
9
+ `table.getState()` → `table.state` / `table.store.state` / `table.atoms.X.get()`,
10
+ `sortingFn` → `sortFn`, `enablePinning` → split, `_`-prefixed APIs unprefixed,
11
+ `ColumnSizing` split into `columnSizingFeature` + `columnResizingFeature`.
12
+ For incremental migration, `useLegacyTable` from `@tanstack/react-table/legacy`
13
+ accepts the v8 API on the v9 engine — deprecated, larger bundle, no
14
+ `table.Subscribe`. Long-term you migrate every table off it.
15
+ type: lifecycle
16
+ library: tanstack-table
17
+ framework: react
18
+ library_version: '9.0.0-alpha.48'
19
+ requires:
20
+ - setup
21
+ - state-management
22
+ - column-definitions
23
+ sources:
24
+ - TanStack/table:docs/framework/react/guide/migrating.md
25
+ - TanStack/table:docs/framework/react/guide/use-legacy-table.md
26
+ - TanStack/table:packages/react-table/src/legacy.ts
27
+ - TanStack/table:examples/react/basic-use-legacy-table/src/main.tsx
28
+ - TanStack/table:examples/react/basic-use-table/src/main.tsx
29
+ ---
30
+
31
+ This skill builds on `tanstack-table/state-management` and `tanstack-table/react/table-state`. Read those first — `state-management` explains _why_ v9 split out `features` / `rowModels`, and `table-state` shows the new reactivity model.
32
+
33
+ ## Two migration paths
34
+
35
+ | Path | Use when | Cost |
36
+ | ---------------------------------------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
37
+ | **Direct: `useReactTable` → `useTable`** | New code, small/medium codebase, or you want React Compiler + Subscribe perf | Per-table refactor; no `getState()` reads in render |
38
+ | **Bridge: `useLegacyTable`** | Large v8 codebase you can't refactor in one PR | Bigger bundle (ships every feature), no `table.Subscribe`, deprecated — pay back later |
39
+
40
+ The bridge is React-only. Angular projects must migrate directly.
41
+
42
+ ## Setup
43
+
44
+ Imports change for v9. The legacy shim lives under `/legacy`.
45
+
46
+ ```tsx
47
+ // v9 (new code)
48
+ import {
49
+ useTable,
50
+ tableFeatures,
51
+ rowSortingFeature,
52
+ rowPaginationFeature,
53
+ columnFilteringFeature,
54
+ columnSizingFeature,
55
+ columnResizingFeature,
56
+ createColumnHelper,
57
+ createSortedRowModel,
58
+ createFilteredRowModel,
59
+ createPaginatedRowModel,
60
+ sortFns,
61
+ filterFns,
62
+ } from '@tanstack/react-table'
63
+
64
+ // Legacy shim (migration aid only)
65
+ import {
66
+ useLegacyTable,
67
+ legacyCreateColumnHelper,
68
+ getCoreRowModel,
69
+ getSortedRowModel,
70
+ getFilteredRowModel,
71
+ getPaginationRowModel,
72
+ } from '@tanstack/react-table/legacy'
73
+ ```
74
+
75
+ ## Direct migration: v8 → v9 line-by-line
76
+
77
+ ### Hooks and helpers
78
+
79
+ ```tsx
80
+ // v8
81
+ import {
82
+ useReactTable,
83
+ createColumnHelper,
84
+ getCoreRowModel,
85
+ getSortedRowModel,
86
+ } from '@tanstack/react-table'
87
+ const columnHelper = createColumnHelper<Person>()
88
+ const table = useReactTable({
89
+ columns,
90
+ data,
91
+ getCoreRowModel: getCoreRowModel(),
92
+ getSortedRowModel: getSortedRowModel(),
93
+ })
94
+
95
+ // v9
96
+ import {
97
+ useTable,
98
+ tableFeatures,
99
+ rowSortingFeature,
100
+ createColumnHelper,
101
+ createSortedRowModel,
102
+ sortFns,
103
+ } from '@tanstack/react-table'
104
+
105
+ const features = tableFeatures({ rowSortingFeature })
106
+ const columnHelper = createColumnHelper<typeof features, Person>()
107
+ const table = useTable({
108
+ features,
109
+ rowModels: { sortedRowModel: createSortedRowModel(sortFns) }, // factory takes *Fns
110
+ columns,
111
+ data,
112
+ })
113
+ ```
114
+
115
+ ### State reads
116
+
117
+ ```tsx
118
+ // v8
119
+ const state = table.getState()
120
+ const cells = row._getAllCellsByColumnId()
121
+
122
+ // v9
123
+ const all = table.state // flat snapshot
124
+ const sorting = table.atoms.sorting.get() // per-slice atom
125
+ const cells = row.getAllCellsByColumnId() // no underscore — APIs unprefixed
126
+ ```
127
+
128
+ In components, prefer `<table.Subscribe>` over `table.state` for reactivity (see `tanstack-table/react/table-state`).
129
+
130
+ ### Renames
131
+
132
+ | v8 | v9 |
133
+ | -------------------------------- | ----------------------------------------------------------- |
134
+ | `sortingFn` (column def) | `sortFn` |
135
+ | `sortingFns` (registry) | `sortFns` |
136
+ | `getSortingFn()` | `getSortFn()` |
137
+ | `getAutoSortingFn()` | `getAutoSortFn()` |
138
+ | `SortingFn` / `SortingFns` types | `SortFn` / `SortFns` |
139
+ | `enablePinning: true` | `enableColumnPinning: true` AND/OR `enableRowPinning: true` |
140
+ | `columnSizingInfo` state | `columnResizing` |
141
+ | `onColumnSizingInfoChange` | `onColumnResizingChange` |
142
+ | `table._getFacetedRowModel` etc. | `table.getFacetedRowModel` etc. (underscore dropped) |
143
+ | `row._getAllCellsByColumnId()` | `row.getAllCellsByColumnId()` |
144
+
145
+ ### Column resizing split
146
+
147
+ ```tsx
148
+ // v8
149
+ useReactTable({
150
+ /* ColumnSizing feature handles BOTH widths AND drag */
151
+ })
152
+
153
+ // v9 — explicit
154
+ const features = tableFeatures({
155
+ columnSizingFeature, // fixed widths
156
+ columnResizingFeature, // drag-to-resize (separate feature)
157
+ })
158
+ ```
159
+
160
+ ### Type generics — `TFeatures` first
161
+
162
+ ```tsx
163
+ // v8
164
+ type MyDef = ColumnDef<Person, string>
165
+ declare module '@tanstack/react-table' {
166
+ interface ColumnMeta<TData, TValue> {
167
+ customProp: string
168
+ }
169
+ }
170
+
171
+ // v9
172
+ type MyDef = ColumnDef<typeof features, Person, string>
173
+ declare module '@tanstack/react-table' {
174
+ interface ColumnMeta<
175
+ TFeatures extends TableFeatures,
176
+ TData extends RowData,
177
+ TValue extends CellData = CellData,
178
+ > {
179
+ customProp: string
180
+ }
181
+ }
182
+ ```
183
+
184
+ `RowData` was also tightened from `unknown | object | any[]` to `Record<string, any> | Array<any>`.
185
+
186
+ ### Mutability
187
+
188
+ `data` and `columns` are `readonly` in v9. Any code that mutates the array in place (`data.push(...)`) will fail at the TS layer; flow changes through `setData(prev => [...prev, row])`.
189
+
190
+ ## Bridge migration: `useLegacyTable`
191
+
192
+ When you need to keep one or many tables on the v8 API while you upgrade others, switch the import path:
193
+
194
+ ```tsx
195
+ // Before: v8 import
196
+ import { useReactTable, getCoreRowModel, getSortedRowModel, getPaginationRowModel, getFilteredRowModel, createColumnHelper, flexRender }
197
+ from '@tanstack/react-table'
198
+
199
+ // After: legacy shim, same call shape
200
+ import {
201
+ useLegacyTable,
202
+ legacyCreateColumnHelper,
203
+ getCoreRowModel, getSortedRowModel, getPaginationRowModel, getFilteredRowModel,
204
+ } from '@tanstack/react-table/legacy'
205
+ import { flexRender } from '@tanstack/react-table'
206
+
207
+ const columnHelper = legacyCreateColumnHelper<Person>()
208
+
209
+ const columns = columnHelper.columns([
210
+ columnHelper.accessor('firstName', { cell: (info) => info.getValue() }),
211
+ // ...
212
+ ])
213
+
214
+ function App({ data }) {
215
+ const [sorting, setSorting] = React.useState([])
216
+ const [pagination, setPagination] = React.useState({ pageIndex: 0, pageSize: 10 })
217
+
218
+ const table = useLegacyTable({
219
+ columns,
220
+ data,
221
+ // v8-style root options — mapped to v9 rowModels under the hood
222
+ getCoreRowModel: getCoreRowModel(),
223
+ getSortedRowModel: getSortedRowModel(),
224
+ getPaginationRowModel: getPaginationRowModel(),
225
+ getFilteredRowModel: getFilteredRowModel(),
226
+ state: { sorting, pagination },
227
+ onSortingChange: setSorting,
228
+ onPaginationChange: setPagination,
229
+ })
230
+
231
+ // Rendering: with useLegacyTable, prefer `flexRender(header.column.columnDef.header, header.getContext())`.
232
+ return (/* same JSX shape as v8 */)
233
+ }
234
+ ```
235
+
236
+ Source: `examples/react/basic-use-legacy-table/src/main.tsx`; `packages/react-table/src/legacy.ts`.
237
+
238
+ Tradeoffs of the bridge:
239
+
240
+ - Bundles every feature (no tree-shaking benefit).
241
+ - No `table.Subscribe`, no `table.atoms`, no fine-grained reactivity — subscribes to all state like v8.
242
+ - **Deprecated in v9, removed in v10.** Use it to unblock incremental migration; don't ship new features against it.
243
+
244
+ ## Common Mistakes
245
+
246
+ ### CRITICAL Keeping `useReactTable` + `get*RowModel` options on v9
247
+
248
+ Wrong:
249
+
250
+ ```tsx
251
+ import { useReactTable, getCoreRowModel } from '@tanstack/react-table'
252
+ const table = useReactTable({
253
+ data,
254
+ columns,
255
+ getCoreRowModel: getCoreRowModel(),
256
+ })
257
+ ```
258
+
259
+ Correct:
260
+
261
+ ```tsx
262
+ import { useTable, tableFeatures } from '@tanstack/react-table'
263
+ const features = tableFeatures({})
264
+ const table = useTable({ features, rowModels: {}, data, columns })
265
+ ```
266
+
267
+ `useReactTable` is the v8 entry point and won't have `table.Subscribe` / `table.atoms`. `getCoreRowModel()` as an option was removed — core is automatic; non-core models move into `rowModels` as factories that take their \*Fns parameter.
268
+ Source: PR #6202; `packages/react-table/src/useTable.ts`.
269
+
270
+ ### CRITICAL `createSortedRowModel()` without `sortFns`
271
+
272
+ Wrong:
273
+
274
+ ```tsx
275
+ rowModels: {
276
+ sortedRowModel: createSortedRowModel()
277
+ }
278
+ ```
279
+
280
+ Correct:
281
+
282
+ ```tsx
283
+ import { createSortedRowModel, sortFns } from '@tanstack/react-table'
284
+ rowModels: {
285
+ sortedRowModel: createSortedRowModel(sortFns)
286
+ }
287
+ ```
288
+
289
+ Each row-model factory in v9 takes its functions registry as a parameter so they can be tree-shaken: `createFilteredRowModel(filterFns)`, `createGroupedRowModel(aggregationFns)`, `createSortedRowModel(sortFns)`.
290
+ Source: `docs/framework/react/guide/migrating.md`.
291
+
292
+ ### CRITICAL `createColumnHelper<Person>()` (v8 arity)
293
+
294
+ Wrong:
295
+
296
+ ```tsx
297
+ const columnHelper = createColumnHelper<Person>()
298
+ ```
299
+
300
+ Correct:
301
+
302
+ ```tsx
303
+ const columnHelper = createColumnHelper<typeof features, Person>()
304
+ ```
305
+
306
+ v9 requires `<TFeatures, TData>`. `typeof features` is the standard idiom — declare features once and reuse the type.
307
+ Source: `docs/framework/react/guide/migrating.md`.
308
+
309
+ ### CRITICAL `table.getState()` reads on v9
310
+
311
+ Wrong:
312
+
313
+ ```tsx
314
+ function Toolbar({ table }) {
315
+ const { rowSelection } = table.getState() // exists on v8, removed on v9
316
+ return <div>{Object.keys(rowSelection).length} selected</div>
317
+ }
318
+ ```
319
+
320
+ Correct:
321
+
322
+ ```tsx
323
+ function Toolbar({ table }) {
324
+ return (
325
+ <table.Subscribe selector={(s) => Object.keys(s.rowSelection).length}>
326
+ {(count) => <div>{count} selected</div>}
327
+ </table.Subscribe>
328
+ )
329
+ }
330
+ ```
331
+
332
+ `getState` was removed. Use `table.state` for a flat snapshot, `table.state` if you passed a `useTable` selector, or `<table.Subscribe>` for reactive reads.
333
+ Source: `docs/framework/react/guide/migrating.md`; `examples/react/basic-subscribe/src/main.tsx`.
334
+
335
+ ### HIGH `enablePinning: true` on v9
336
+
337
+ Wrong:
338
+
339
+ ```tsx
340
+ useTable({ features, rowModels: {}, columns, data, enablePinning: true })
341
+ ```
342
+
343
+ Correct:
344
+
345
+ ```tsx
346
+ useTable({
347
+ features,
348
+ rowModels: {},
349
+ columns,
350
+ data,
351
+ enableColumnPinning: true,
352
+ enableRowPinning: true,
353
+ })
354
+ ```
355
+
356
+ `enablePinning` was split. Pick one or both depending on what you actually want.
357
+ Source: `docs/framework/react/guide/migrating.md`.
358
+
359
+ ### HIGH `_`-prefixed APIs
360
+
361
+ Wrong:
362
+
363
+ ```tsx
364
+ row._getAllCellsByColumnId()
365
+ table._getFacetedRowModel()
366
+ table._getFacetedMinMaxValues()
367
+ ```
368
+
369
+ Correct:
370
+
371
+ ```tsx
372
+ row.getAllCellsByColumnId()
373
+ table.getFacetedRowModel()
374
+ table.getFacetedMinMaxValues()
375
+ ```
376
+
377
+ All went public — drop the underscore.
378
+ Source: `docs/framework/react/guide/migrating.md`.
379
+
380
+ ### HIGH Module augmentation with v8 generic arity
381
+
382
+ Wrong:
383
+
384
+ ```tsx
385
+ declare module '@tanstack/react-table' {
386
+ interface ColumnMeta<TData, TValue> {
387
+ customProp: string
388
+ }
389
+ }
390
+ ```
391
+
392
+ Correct:
393
+
394
+ ```tsx
395
+ declare module '@tanstack/react-table' {
396
+ interface ColumnMeta<
397
+ TFeatures extends TableFeatures,
398
+ TData extends RowData,
399
+ TValue extends CellData = CellData,
400
+ > {
401
+ customProp: string
402
+ }
403
+ }
404
+ ```
405
+
406
+ v9 added `TFeatures` as the first generic on `ColumnMeta` / `Column` / `Row` / `ColumnDef`. Wrong arity silently widens the augmentation.
407
+ Source: `examples/react/basic-use-legacy-table/src/main.tsx` (correct shape).
408
+
409
+ ### MEDIUM Mutating `data` or `columns` in place
410
+
411
+ Wrong:
412
+
413
+ ```tsx
414
+ const data = []
415
+ function addRow(row) {
416
+ data.push(row)
417
+ rerender()
418
+ }
419
+ ```
420
+
421
+ Correct:
422
+
423
+ ```tsx
424
+ const [data, setData] = React.useState<Person[]>([])
425
+ function addRow(row: Person) {
426
+ setData((prev) => [...prev, row])
427
+ }
428
+ ```
429
+
430
+ PR #6183 made `data` and `columns` `readonly` to force changes through React state.
431
+ Source: `docs/framework/react/guide/migrating.md`.
432
+
433
+ ### MEDIUM Treating `useLegacyTable` as a long-term answer
434
+
435
+ Wrong:
436
+
437
+ ```tsx
438
+ // New feature shipped on the legacy shim — locks in the bigger bundle indefinitely.
439
+ import { useLegacyTable } from '@tanstack/react-table/legacy'
440
+ ```
441
+
442
+ Correct:
443
+
444
+ ```tsx
445
+ // New tables: useTable. Reach for the legacy shim only when migrating an existing v8 table piecemeal.
446
+ import { useTable, tableFeatures } from '@tanstack/react-table'
447
+ ```
448
+
449
+ `useLegacyTable` is deprecated in v9 and scheduled for removal in v10. It exists to unblock incremental migration, not to be a permanent API.
450
+ Source: `docs/framework/react/guide/use-legacy-table.md`.
451
+
452
+ ### CRITICAL Hallucinating react-table v7 / `useTable(opts, useSortBy)` shape
453
+
454
+ Wrong:
455
+
456
+ ```tsx
457
+ import { useTable, useSortBy } from 'react-table' // v7 package name + plugin hooks
458
+ const table = useTable({ columns, data }, useSortBy)
459
+ ```
460
+
461
+ Correct:
462
+
463
+ ```tsx
464
+ import {
465
+ useTable,
466
+ tableFeatures,
467
+ rowSortingFeature,
468
+ createSortedRowModel,
469
+ sortFns,
470
+ } from '@tanstack/react-table'
471
+ const features = tableFeatures({ rowSortingFeature })
472
+ const table = useTable({
473
+ features,
474
+ rowModels: { sortedRowModel: createSortedRowModel(sortFns) },
475
+ columns,
476
+ data,
477
+ })
478
+ ```
479
+
480
+ The `react-table` package (v7) was renamed to `@tanstack/react-table` in v8 and reshaped again in v9. Agents trained on pre-v9 data will produce all three shapes — only the v9 shape compiles today.
481
+ Source: maintainer interview (Phase 4).
482
+
483
+ ## See Also
484
+
485
+ - `tanstack-table/react/getting-started` — the v9 minimum-viable shape.
486
+ - `tanstack-table/react/table-state` — replacing `getState()` with selectors / `<Subscribe>`.
487
+ - `tanstack-table/react/production-readiness` — tree-shaking with `features` (the whole point of the v9 redesign).
488
+ - `tanstack-table/react/react-subscribe-compiler-compat` — fixes the v8-React-Compiler "incompatible library" warning.