본문으로 건너뛰기
cccskills
무료GitHub에 공개

tanstack-table

TanStack Table best practices for building headless, type-safe data tables in React with sorting, filtering, pagination, row selection, and column management. Use when building data grids, implementing client-side or server-side table features, defining column structures, managing table state, or optimizing table rendering performance.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(12)

  • SKILL.md7.0 KB
  • rules/col-column-defs.md3.1 KB
  • rules/exp-expanding.md2.8 KB
  • rules/filt-column-filtering.md3.0 KB
  • rules/filt-global-filtering.md2.1 KB
  • rules/pag-pagination.md2.6 KB
  • rules/rm-row-models.md3.1 KB
  • rules/sel-row-selection.md2.4 KB
  • rules/size-column-sizing.md2.6 KB
  • rules/sort-sorting.md2.8 KB
  • rules/table-setup.md3.2 KB
  • rules/vis-column-visibility.md1.9 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

TanStack Table

Version: @tanstack/react-table@latest Requires: React 16.8+, TypeScript recommended

Quick Setup

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>
  )
}

Row Models (Import Only What You Need)

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

Rule Categories

PriorityCategoryRule FileImpact
CRITICALTable Setuprules/table-setup.mdCorrect table creation, stable data references
CRITICALColumn Definitionsrules/col-column-defs.mdData model, rendering, type safety
CRITICALRow Modelsrules/rm-row-models.mdModular imports, pipeline order
HIGHSortingrules/sort-sorting.mdClient/server sorting, custom sort functions
HIGHColumn Filteringrules/filt-column-filtering.mdPer-column filters, custom filter functions
HIGHGlobal Filteringrules/filt-global-filtering.mdTable-wide search, global filter function
HIGHPaginationrules/pag-pagination.mdClient/server pagination, page state
MEDIUMRow Selectionrules/sel-row-selection.mdCheckbox/radio selection, selection state
MEDIUMColumn Visibilityrules/vis-column-visibility.mdShow/hide columns dynamically
MEDIUMColumn Sizingrules/size-column-sizing.mdWidths, resizing, performance
LOWExpandingrules/exp-expanding.mdSub-rows, detail panels, hierarchical data

Critical Rules

Always Do

  • Stable data reference — use useState, useMemo, or define outside component to prevent infinite re-renders
  • Use createColumnHelper<TData>() — for maximum type safety in column definitions
  • Import only needed row models — don't import getSortedRowModel if you don't sort client-side
  • Use flexRender — for rendering header/cell/footer templates from column defs
  • Use getVisibleCells() — not getAllCells(), to respect column visibility
  • Use getRowModel() — the final row model that applies all features (filtering, sorting, pagination)
  • Control state with state + on*Change — for sorting, filtering, pagination, selection, etc.

Never Do

  • Define data inline — useReactTable({ data: fetchData() }) causes infinite re-renders
  • Define columns inside render — columns array must be stable (define outside component or useMemo)
  • Use getAllCells() for rendering — ignores column visibility; use getVisibleCells()
  • Mix initialState and state for the same feature — state overrides initialState
  • Use client-side row models with manual* options — if manualSorting: true, don't import getSortedRowModel
  • Forget getRowId — without it, row IDs default to index, breaking selection state across re-fetches

Key Patterns

// 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({
  id: 'select',
  header: ({ table }) => (
    <input type="checkbox" checked={table.getIsAllRowsSelected()}
      onChange={table.getToggleAllRowsSelectedHandler()} />
  ),
  cell: ({ row }) => (
    <input type="checkbox" checked={row.getIsSelected()}
      disabled={!row.getCanSelect()}
      onChange={row.getToggleSelectedHandler()} />
  ),
})

// Column filtering
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([])
const table = useReactTable({
  data, columns,
  getCoreRowModel: getCoreRowModel(),
  getFilteredRowModel: getFilteredRowModel(),
  state: { columnFilters },
  onColumnFiltersChange: setColumnFilters,
})
// Filter input
<input value={column.getFilterValue() ?? ''} onChange={e => column.setFilterValue(e.target.value)} />

// Stable row IDs for selection across re-fetches
const table = useReactTable({
  data, columns,
  getRowId: (row) => row.uuid,
  getCoreRowModel: getCoreRowModel(),
})

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Implement web accessibility (a11y) best practices following WCAG guidelines to create inclusive, accessible user interfaces.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

fellipeutaka/kanpeki332026년 8월 28일 업데이트

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

fellipeutaka/kanpeki332026년 8월 28일 업데이트

bun

무료

Bun runtime, package manager, bundler, and test runner. Use when running scripts with bun, managing packages, serving HTTP with Bun.serve, querying databases with Bun.sql/bun:sqlite/Bun.redis, shell scripting with $, using S3/file I/O, writing tests with bun:test, bundling or compiling to executable, or using any Bun-specific API (spawn, glob, semver, FFI, workers, plugins, HTMLRewriter).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

fellipeutaka/kanpeki332026년 8월 28일 업데이트

Create high-quality git commits: review/stage intended changes, split into logical commits, and write clear commit messages (including Conventional Commits). Use when the user asks to commit, craft a commit message, stage changes, or split work into multiple commits.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

fellipeutaka/kanpeki332026년 8월 28일 업데이트

denji

무료

Manage SVG icons as framework components using Denji CLI. Use when the user needs to add, remove, list, or manage SVG icons in React, Preact, Solid, Qwik, Vue, or Svelte projects. Triggers include requests to "add an icon", "set up icons", "manage SVG icons", "remove an icon", "list icons", or any task involving Iconify icons as framework components.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

fellipeutaka/kanpeki332026년 8월 28일 업데이트

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

fellipeutaka/kanpeki332026년 8월 28일 업데이트

fellipeutaka의 스킬 모두 보기

이 스킬의 문제 신고