用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill tanstack-table命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
| name | tanstack-table |
| description | | Use when this capability is needed. |
Version: @tanstack/react-table@latest Requires: React 16.8+, TypeScript recommended
npm install @tanstack/react-table
import {
useReactTable,
getCoreRowModel,
flexRender,
createColumnHelper,
} from '@tanstack/react-table'
type User = {
name: string
age: number
status: string
}
const columnHelper = createColumnHelper<User>()
const columns = [
columnHelper.accessor('name', { header: 'Name' }),
columnHelper.accessor('age', { header: 'Age' }),
columnHelper.accessor('status', { header: 'Status' }),
columnHelper.display({
id: 'actions',
cell: (props) => <button onClick={() => edit(props.row.original)}>Edit</button>,
}),
]
function App() {
const [data] = useState<User[]>([]) // must be stable reference
const table = useReactTable({
data,
columns,
getCoreRowModel: getCoreRowModel(),
})
return (
<table>
<thead>
{table.getHeaderGroups().map((headerGroup) => (
<tr key={headerGroup.id}>
{headerGroup.headers.map((header) => (
<th key={header.id}>
{flexRender(header.column.columnDef.header, header.getContext())}
</th>
))}
</tr>
))}
</thead>
<tbody>
{table.getRowModel().rows.map((row) => (
<tr key={row.id}>
{row.getVisibleCells().map((cell) => (
<td key={cell.id}>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</td>
))}
</tr>
))}
</tbody>
</table>
)
}
TanStack Table is modular. Only import the row models you actually use:
import {
getCoreRowModel, // required
getSortedRowModel, // client-side sorting
getFilteredRowModel, // client-side filtering
getPaginationRowModel,// client-side pagination
getExpandedRowModel, // expanding/sub-rows
getGroupedRowModel, // grouping + aggregation
getFacetedRowModel, // faceted values
getFacetedUniqueValues,
getFacetedMinMaxValues,
} from '@tanstack/react-table'
Pipeline order: Core -> Filtered -> Grouped -> Sorted -> Expanded -> Paginated -> Rendered
| Priority | Category | Rule File | Impact |
|---|---|---|---|
| CRITICAL | Table Setup | rules/table-setup.md | Correct table creation, stable data references |
| CRITICAL | Column Definitions | rules/col-column-defs.md | Data model, rendering, type safety |
| CRITICAL | Row Models | rules/rm-row-models.md | Modular imports, pipeline order |
| HIGH | Sorting | rules/sort-sorting.md | Client/server sorting, custom sort functions |
| HIGH | Column Filtering | rules/filt-column-filtering.md | Per-column filters, custom filter functions |
| HIGH | Global Filtering | rules/filt-global-filtering.md | Table-wide search, global filter function |
| HIGH | Pagination | rules/pag-pagination.md | Client/server pagination, page state |
| MEDIUM | Row Selection | rules/sel-row-selection.md | Checkbox/radio selection, selection state |
| MEDIUM | Column Visibility | rules/vis-column-visibility.md | Show/hide columns dynamically |
| MEDIUM | Column Sizing | rules/size-column-sizing.md | Widths, resizing, performance |
| LOW | Expanding | rules/exp-expanding.md | Sub-rows, detail panels, hierarchical data |
data reference — use useState, useMemo, or define outside component to prevent infinite re-renderscreateColumnHelper<TData>() — for maximum type safety in column definitionsgetSortedRowModel if you don't sort client-sideflexRender — for rendering header/cell/footer templates from column defsgetVisibleCells() — not getAllCells(), to respect column visibilitygetRowModel() — the final row model that applies all features (filtering, sorting, pagination)state + on*Change — for sorting, filtering, pagination, selection, etc.data inline — useReactTable({ data: fetchData() }) causes infinite re-renderscolumns inside render — columns array must be stable (define outside component or useMemo)getAllCells() for rendering — ignores column visibility; use getVisibleCells()initialState and state for the same feature — state overrides initialStatemanual* options — if manualSorting: true, don't import getSortedRowModelgetRowId — without it, row IDs default to index, breaking selection state across re-fetches// Controlled sorting state
const [sorting, setSorting] = useState<SortingState>([])
const table = useReactTable({
data, columns,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
state: { sorting },
onSortingChange: setSorting,
})
// Header click handler
<th onClick={header.column.getToggleSortingHandler()}>
{flexRender(header.column.columnDef.header, header.getContext())}
{{ asc: ' 🔼', desc: ' 🔽' }[header.column.getIsSorted() as string] ?? ''}
</th>
// Server-side pagination
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 })
const table = useReactTable({
data, columns,
getCoreRowModel: getCoreRowModel(),
manualPagination: true,
rowCount: serverData.totalRows,
state: { pagination },
onPaginationChange: setPagination,
})
// Row selection with checkbox column
columnHelper.display({
: ,
: (
),
: (
),
})
[columnFilters, setColumnFilters] = useState<>([])
table = ({
data, columns,
: (),
: (),
: { columnFilters },
: setColumnFilters,
})
<input value={column.() ?? } onChange={ column.(e..)} />
table = ({
data, columns,
: row.,
: (),
})
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
基于 SOC 职业分类