0PricingLogin
React Academy · Lesson

Defining Columns and Rendering Rows

Configure column definitions with accessors, headers, and cell renderers to display your data.

The ColumnDef Type

Every column in TanStack Table is described by a ColumnDef object. The two most important fields are accessorKey (the property name on your data object) and header (the column label string or render function).

The accessorKey approach is ideal for flat data; complex or computed values need accessorFn.

accessorKey vs accessorFn

When your data has a direct property like name or email, use accessorKey: 'name'. When you need to compute a value (e.g., combining firstName and lastName), use accessorFn: row => row.firstName + ' ' + row.lastName.

Both are fully typed when you provide the row data generic to ColumnDef.

All lessons in this course

  1. TanStack Table Philosophy and Headless Design
  2. Defining Columns and Rendering Rows
  3. Sorting, Filtering, and Pagination
  4. Row Selection and Virtualized Tables
← Back to React Academy