Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)29k · #9835

custom-features

Skill này làm gì

Skill này chỉ cách xây dựng một tính năng tái sử dụng, hay plugin, để thêm state hoặc hành vi mới cho TanStack Table. Skill dành cho lập trình viên nâng cao có nhu cầu mà các tính năng có sẵn chưa đáp ứng.

Khi nào nên dùng

  • ✓Khi bạn cần state hoặc hành vi tái sử dụng được thêm vào các object của bảng.
  • ✓Khi các tùy chọn có sẵn và meta có kiểu không xử lý được renderer hoặc thiết lập ứng dụng của bạn.
  • ✓Khi bạn viết một plugin phải đăng ký đúng các hook vòng đời và phương thức của bảng.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/TanStack/table/blob/main/packages/table-core/skills/custom-features/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Các tính năng TanStack Table có sẵn không đáp ứng được nhu cầu của tôi. Làm sao để tự viết plugin?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill đi qua các bước khai báo tính năng, giữ state do người dùng cung cấp, thêm phương thức cho bảng và object trong các hook vòng đời, rồi đăng ký plugin bằng một object tính năng ổn định.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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.

Câu hỏi thường gặp

Khi nào tôi không nên viết tính năng tùy chỉnh?

Skill nói nếu hành vi chỉ truyền callback hoặc dữ liệu renderer thì nên dùng meta có kiểu.

Khai báo kiểu của tính năng có cài đặt hành vi không?

Không. Skill nói riêng khai báo không cài đặt gì cả, nên phần triển khai lúc chạy phải khớp với các kiểu đã khai báo.

Plugin nên đăng ký ở đâu?

Qua lệnh gọi tableFeatures, để việc suy luận kiểu và ghép tổ hợp đều bao gồm nó.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
29k
Vị trí xếp hạng
#9835
Giấy phép
MIT
Cập nhật
21/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự