Skip to content

DataTable: toggling one row's selection re-renders every cell #8716

Open

Description

@mattcosta7

Part of #8676 (P1). Measure with #8714 before and after.

Problem

DataTable/useTable.ts (createRow, about :292-318) builds new row and cell objects on every render, with selected baked in at :309. TableRow (Table.tsx:264) and TableCell (:289) aren't memoized. Every row and cell therefore re-renders whenever any selection changes.

Measured: with 200 rows by 3 columns, mounting calls renderCell 600 times. Toggling one row's checkbox calls it 600 more times.

Passing a new data array also re-sorts and rebuilds every row (useTable.ts:177-181).

Proposed fix

  • Cache row objects by source row plus selected and selectable, so unchanged rows keep their identity.
  • Render rows through a memoized row component.
  • Document that data and columns should be referentially stable.

The fix must work on React 18 and 19.

Acceptance criteria

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions