本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)29k · #9835

custom-features

できること

テーブルに新しい状態や動作を追加する、再利用可能な機能(プラグイン)の作り方を示します。組み込み機能では対応できない要件を持つ上級開発者向けです。

使う場面

  • ✓テーブルのオブジェクトに、再利用できる状態や動作を追加する必要があるとき。
  • ✓組み込みのオプションやtyped metaでは、レンダラーやアプリの設定に対応できないとき。
  • ✓ライフサイクルのフックとテーブルのメソッドを正しく登録するプラグインを書くとき。

スキルのリンク

https://github.com/TanStack/table/blob/main/packages/table-core/skills/custom-features/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/TanStack/table/blob/main/packages/table-core/skills/custom-features/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“TanStack Tableの組み込み機能では必要なことが実現できません。独自のプラグインの書き方を教えてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

機能を宣言し、ユーザーの状態を保持し、ライフサイクルのフックの中でテーブルとオブジェクトのメソッドを追加し、安定した機能オブジェクトとしてプラグインを登録する手順を説明します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Author a custom feature

Read core and feature architecture first. Use a plugin for reusable state or behavior that must augment Table objects. Built-in options and typed tableMeta/columnMeta are usually enough for renderer callbacks and application configuration.

Implementation workflow

  1. Identify the state, options, and object methods the behavior owns. If it only passes callbacks or renderer data, read scoped meta typing and use meta instead.
  2. Before declaring plugin types or writing lifecycle hooks, read the complete plugin example. It enumerates all 10 public FeatureMaps, the API assignment helpers, lifecycle ordering, and the advanced row-model maps.
  3. Declare the feature key in Plugins. Merge only FeatureMaps with matching runtime implementations; declarations alone install no behavior.
  4. Preserve user state after defaults in getInitialState; connect state updaters in default options. Install table methods with assignTableAPIs and object methods with assignPrototypeAPIs inside the corresponding lifecycle hooks.
  5. Keep the feature object and tableFeatures({ customFeature }) result stable. Register the plugin through tableFeatures so inference and composition include it.
  6. Verify the advertised state, options, methods, and resets on a constructed table. Each declared API must exist at runtime; reset behavior must respect the state owner.

Lifecycle boundaries

Use initTableInstanceData for mutable data owned by one table and resetTableInstanceData for clearing its transient contents. All feature initialization finishes before any constructTableAPIs hook. Keep method installation separate from data allocation.

Prototype methods are shared across the table's rows, columns, cells, or headers. Read per-object values through the method's current instance, and use the supported instance-data hooks for mutable fields. Read the example's installation rules before adding memoized methods or advanced row-model/cache wiring.

Common failures

  • Types without matching runtime hooks advertise APIs that do not exist.
  • Ad hoc mutation of constructed instances bypasses feature registration and inferred composition.
  • Treating the density example as the only extension pattern misses column definitions and the other public FeatureMaps. Choose the maps required by the behavior; advanced row-model declarations also require runtime pipeline/cache wiring.

Installed API discovery

Inspect node_modules/@tanstack/table-core/dist/types/TableFeatures.d.ts, the exported *_FeatureMap interfaces in dist/types/, and assignTableAPIs/assignPrototypeAPIs in dist/utils.d.ts. Follow declarations under dist/features/ for comparable stock lifecycle signatures.

よくある質問

カスタム機能を作るべきでないのはどんな場合ですか?

動作がコールバックやレンダラーのデータを渡すだけなら、代わりにtyped metaを使うべきだと、このスキルは説明しています。

機能の型を宣言すると動作も組み込まれますか?

いいえ。宣言だけでは何も組み込まれず、実行時の実装は宣言された型と一致させる必要があると説明しています。

プラグインはどこで登録すればよいですか?

tableFeatures呼び出しを通じて登録します。そうすれば型推論と合成に含まれます。

詳細

作者による元の説明

Implement a Table v9 plugin when built-ins and typed meta are insufficient. Covers FeatureMaps, runtime lifecycle hooks, prototypes, and a complete checked example.

repo: TanStack/table

人気

GitHubのスター
29k
ランキング
#9835
ライセンス
MIT
更新日
2026/10/21

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル