table-state
Skill này làm gì
Skill này giải thích cách giữ các thiết lập của bảng, như trang hiện tại, trong state React và cách bảng đọc chúng. Skill dành cho lập trình viên React cần giao diện khớp với state của bảng.
Khi nào nên dùng
- ✓Khi một component React cần hiển thị trang hiện tại hoặc một thiết lập khác của bảng.
- ✓Khi bạn cần truyền một thiết lập của bảng từ component của mình vào bảng.
- ✓Khi giao diện React không cập nhật sau khi một thiết lập của bảng thay đổi.
Liên kết skill
https://github.com/TanStack/table/blob/main/packages/react-table/skills/table-state/SKILL.mdSao 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
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Làm sao để cập nhật số trang trong bảng React của tôi sau khi tôi bấm nút sang trang tiếp theo?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill chỉ cách lưu thiết lập bằng hook state của React, truyền nó cho bảng cùng callback cập nhật tương ứng và đọc state đã chọn để giao diện render lại.
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.
React table state
Before starting, run intent load @tanstack/table-core#table-state for shared ownership, initialization, updates, and resets. State repair does not require loading setup guidance.
Read reactive state
useTable selects all registered state by default. Its optional second-argument selector controls rerenders and the shape of table.state. table.atoms.<slice>.get() and table.store.state are current snapshots, not React subscriptions.
Use selected table.state in the owner render. For narrower boundaries, use table.Subscribe or useSelector from @tanstack/react-store. Without source, table.Subscribe selects from table.store; with source, it subscribes to that atom or store. Start with the default selector until render cost requires narrowing.
Control a slice
Keep features, columns, and data stable. Register the feature that owns the controlled slice. This example controls pagination without adding client row processing:
import { useState } from 'react'
import {
rowPaginationFeature,
tableFeatures,
useTable,
type PaginationState,
} from '@tanstack/react-table'
const features = tableFeatures({ rowPaginationFeature })
const columns = [{ accessorKey: 'name' }]
const data = [{ name: 'Ada' }]
export function PageControl() {
const [pagination, setPagination] = useState<PaginationState>({
pageIndex: 0,
pageSize: 20,
})
const table = useTable({
features,
columns,
data,
state: { pagination },
onPaginationChange: setPagination,
})
return (
<button onClick={() => table.setPageSize(50)}>
{table.state.pagination.pageSize} rows per page
</button>
)
}
The React setter accepts both a value and a functional updater. Supply the current state.pagination together with onPaginationChange; a callback alone does not keep the table synchronized.
For an externally owned atom, create it with useCreateAtom from @tanstack/react-store, pass it in atoms.<slice>, and subscribe with useSelector where other UI needs its value.
Reactive boundaries
For React Compiler memoized children, put Subscribe inside the component hiding builder-method reads or pass the selected value as a changing prop. An outer subscription that ignores its value cannot refresh a stable child. In core-typed cell/header contexts, import standalone Subscribe.
For external-atom examples, selector dependencies, or fine-grained boundaries and React Compiler problems, read reactivity details. If this task changes processing features, run intent load @tanstack/table-core#table-features and read the relevant feature references.
API discovery
Inspect node_modules/@tanstack/react-table/dist/useTable.d.ts and Subscribe.d.ts, plus the installed @tanstack/react-store declarations for atom hooks.
Câu hỏi thường gặp
Vì sao giá trị đọc trong event handler có vẻ đã cũ?
Giá trị đọc trong handler là một bản chụp tại thời điểm đó, nên giao diện chỉ cập nhật từ state đã chọn hoặc từ một subscription.
Tôi có cần cả giá trị lẫn callback không?
Có. Skill nói nên truyền mỗi giá trị được điều khiển cùng callback cập nhật của nó để các thay đổi quay lại đúng cách.
Tôi có thể thu hẹp phần render lại không?
Được. Có các subscription hẹp hơn, nhưng skill khuyên dùng mặc định cho đến khi chi phí render buộc phải thu hẹp.
Chi tiết
Mô tả gốc của tác giả
Read and control Table v9 state in react. Use for tracked reads, subscriptions, controlled slices, and framework-specific reactive boundaries.
repo: TanStack/table
Độ phổ biến
- Sao GitHub
- 29k
- Vị trí xếp hạng
- #9826
- Giấy phép
- MIT
- Cập nhật
- 21/10/2026
Bình luận
- …
Thêm skill từ kho mã này
getting-started
29kHướng dẫn agent của bạn cách tạo và hiển thị bảng dữ liệu với TanStack Table trong Alpine.js, gồm thiết lập, dữ liệu phản ứng và hiển thị các hàng.
table-state
29kHướng dẫn agent của bạn cách đọc và điều khiển trạng thái bảng trong Alpine.js, như trang hiện tại, để màn hình cập nhật khi trạng thái đó thay đổi.
devtools
29kHướng dẫn agent của bạn cách đăng ký bảng Angular với bảng điều khiển TanStack Devtools, để lập trình viên có thể kiểm tra từng bảng trong khi xây dựng ứng dụng.
getting-started
29kHướng dẫn agent của bạn cách tạo và hiển thị bảng TanStack trong Angular, gồm thiết lập injectTable, hiển thị trong template và cập nhật dữ liệu hàng.
Skill tương tự
angular-developer
280kGiúp agent của bạn viết code Angular và tư vấn cấu trúc dự án, hữu ích khi bắt đầu dự án mới hoặc cải thiện hiệu suất.
frontend-a11y
280kGiúp agent của bạn làm cho giao diện web dễ tiếp cận với mọi người. Đảm bảo website và ứng dụng hoạt động tốt với trình đọc màn hình và điều hướng bằng bàn phím.
frontend-patterns
280kGiúp agent của bạn áp dụng các mẫu hiện đại trong phát triển frontend. Tối ưu hiệu năng, quản lý trạng thái và tuân theo thực hành tốt nhất với React và Next.js.