[Table] Context from a wrapper around Column is lost when the column header renders

オープン
#10,632 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
react, typescript
領域
frontend

調査の方向性

Start with the minimal Table/Column reproduction using react-aria-components 1.21.1, @tanstack/react-table 9.2.4, and React 19.3.0, then trace how RAC collects and renders Column header content. Confirm the failure of useHeaderContext() and investigate whether the provider can remain available or whether a renderer API is needed. Done means the header context works through Column rendering, or a documented way exists to pass the collected header instance explicitly.

索引モデルが issue の本文から書いたものです。

説明

Description

I am integrating TanStack Table v9's createTableHook with React Aria Components Table. TanStack’s hook factory can register header components that use a context hook such as useHeaderContext() to access the current TanStack header's state.

This works when the registered component is rendered in the normal React tree. It fails when used as the content of a React Aria Column: RAC collects the column definitions and renders their header content through its collection machinery, outside the wrapper’s context provider.

This seems related to #7049: “Context set in collection item node not propagating”, which describes the same general context-propagation problem. This report is a concrete Table/Column integration case.

Minimal example

A simplified TanStack hook registers a component that reads the current header from context:

const { useAppTable, useHeaderContext } = createTableHook({
  features,
  headerComponents: {
    SortableHeader: () => {
      const header = useHeaderContext();

      return (
        <Column
          id={header.id}
          allowsSorting={header.column.getCanSort()}
        >
          <FlexRender header={header} />
        </Column>
      );
    },
  },
});

The app wraps that component in TanStack’s header provider:

<table.AppTable>
  <Table>
    <TableHeader>
      {headers.map((header) => (
        <table.AppHeader header={header} key={header.id}>
          {(appHeader) => <appHeader.SortableHeader />}
        </table.AppHeader>
      ))}
    </TableHeader>
    {/* rows */}
  </Table>
</table.AppTable>

At runtime, useHeaderContext() throws:

useHeaderContext must be used within an AppHeader or AppFooter component.

Passing the header explicitly instead of reading it from context works around the problem:

<Column id={header.id} allowsSorting={header.column.getCanSort()}>
  <FlexRender header={header} />
</Column>

Expected behavior

A React context provider around a Column’s rendered header content would remain available to that content, or RAC would provide an API for passing the collected column/header instance to the renderer without relying on context.

Actual behavior

The provider appears to wrap the JSX returned for the column, but the content rendered by RAC’s collection-based table header does not receive that context.

Environment

  • react-aria-components: 1.21.1
  • @tanstack/react-table: 9.2.4
  • React: 19.3.0
主要言語
TypeScript
スター
16k
フォーク
1.6k
平均マージ
3日 9時間
マージ済み PR(30日)
45

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

adobe/react-spectrum のほかの issue

adobe/react-spectrum の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。