examples/react/material-react-table
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
Material React Table β TanStack Table v9 example#
This example is a downloadable, self-contained adaptation of material-react-table v3 ported to TanStack Table v9 + Material UI v9.
The full MRT source lives under src/material-react-table/ β it is a 1:1 mirror of the upstream package's src/ (components, hooks, utils, fns, locales). The demo entry point in src/main.tsx shows how to wire it up.
Differences from upstream MRT v3#
The upstream package targets TanStack Table v8 + MUI v6. This example has been migrated:
useReactTableβuseTable(TanStack Table v9 hook).- Row models:
getCoreRowModel/getSortedRowModel/etc. options replaced with_features: stockFeaturesand_rowModels: { sortedRowModel: createSortedRowModel(sortFns), β¦ }. createRowβconstructRow(renamed v9 export).sortingFnβsortFnon column defs and theMRT_SortFntype.columnSizingInfostate βcolumnResizing(andsetColumnSizingInfoβsetColumnResizing).table.getState()βtable.stateacross all ~48 consumer sites.- Type generics: every
MRT_*type now bindsTFeatures = StockFeaturesso consumers don't need to specify it. - MUI v9:
componentsPropsβslotProps(one site).
The example uses the v9 escape-hatch useTable(opts, state => state) β every state change re-renders the consumer, matching v8 semantics. If you'd prefer fine-grained re-renders, swap the selector for narrower projections or use table.Subscribe/per-slice table.atoms.
Running#
pnpm install
pnpm dev
Then open <http://localhost:5173>.
Caveats#
@mui/x-date-pickersis pinned to^8inpackage.jsonbecause there is no v9 release. The MRT date-picker filter variant is therefore wired up but not exercised by the demo (no date columns). If install fails because of a peer-dep mismatch with@mui/material@^9, either add an override in your localpnpm-workspace.yamlor remove@mui/x-date-pickersfrompackage.jsonand delete the date-picker imports insrc/material-react-table/components/inputs/MRT_FilterTextField.tsxandsrc/material-react-table/types.ts.
Credits#
Original library by Kevin Vandy β <https://github.com/KevinVandy/material-react-table>.