Capítulo 7 de 54
useLegacyTable (from @tanstack/react-table/legacy) is a deprecated compatibility shim that accepts the v8-style API (getCoreRowModel, state/on[X]Change, legacyCreateColumnHelper) while running on v9 internals — a temporary bridge for large codebases that can't migrate every table at once.
flexRender, shared state types like SortingState) still come from @tanstack/react-table; legacy-specific APIs (useLegacyTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel, legacyCreateColumnHelper, LegacyColumnDef) come from the separate @tanstack/react-table/legacy entrypoint.getCoreRowModel(), getSortedRowModel(), etc. directly as options, and manage state/onSortingChange/onColumnFiltersChange/onPaginationChange yourself with useState, exactly like Table v8.legacyCreateColumnHelper<T>() mirrors v8's createColumnHelper (.accessor(...), .display(...)), producing LegacyColumnDef<T>[].useLegacyTable includes all features by default (no tree-shaking), so it is strictly larger than an equivalent v9 useTable table — this is the price of the compatibility layer, not a bug.import { useState } from 'react'
import { flexRender } from '@tanstack/react-table'
import {
useLegacyTable,
getCoreRowModel,
getSortedRowModel,
legacyCreateColumnHelper,
} from '@tanstack/react-table/legacy'
import type { SortingState } from '@tanstack/react-table'
const columnHelper = legacyCreateColumnHelper<Person>()
const columns = [
columnHelper.accessor('name', { header: 'Name' }),
columnHelper.accessor('age', { header: 'Age' }),
]
function LegacyPersonTable({ data }: { data: Person[] }) {
const [sorting, setSorting] = useState<SortingState>([])
const table = useLegacyTable({
columns,
data,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
state: { sorting },
onSortingChange: setSorting,
})
// render exactly like a v8 table: flexRender(header.column.columnDef.header, header.getContext())
}
state) still compiles and runs against v9.useLegacyTable only as a bridge, table by table, never as the new default — it's deprecated on arrival and ships every feature (no tree-shaking).@tanstack/react-table/legacy, a different entrypoint than the rest of v9 — mixing them up is the most common setup mistake.useLegacyTable → useTable, getCoreRowModel()-as-option → tableFeatures({ ... }), and legacyCreateColumnHelper → the current createColumnHelper, one table at a time.@tanstack/react-table/legacy.