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

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 của Octane và hiển thị chúng trên màn hình. Skill dành cho lập trình viên cần bảng và trang luôn khớp nhau.

Khi nào nên dùng

  • ✓Khi một nút trên trang phải hiển thị trang bảng hiện tại và cập nhật nó khi bấm.
  • ✓Khi bạn cần truyền một thiết lập bảng từ state của Octane vào bảng.
  • ✓Khi một giá trị bảng không làm mới trên màn hình sau khi nó thay đổi.

Liên kết skill

https://github.com/TanStack/table/blob/main/packages/octane-table/skills/table-state/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/octane-table/skills/table-state/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

“Làm sao để giữ số trang trong bảng Octane của tôi luôn cập nhật trên màn hình khi tôi bấm 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 giữ thiết lập trong state của Octane, truyền cả giá trị lẫn hàm cập nhật của nó cho bảng, và đọc trạng thái được chọn trong markup.

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.

Load intent load @tanstack/table-core#table-state first for shared ownership, initialization, updater, and reset rules.

useTable selects all registered state by default. Its second argument changes the selected shape exposed as table.state and shallow-gates owner rerenders. Atom .get() and table.store.state reads are snapshots; use selected state or a rendered table.Subscribe to update the UI.

Controlled slice setup

import { useState } from 'octane'
import {
  rowPaginationFeature,
  tableFeatures,
  useTable,
} from '@tanstack/octane-table'

const features = tableFeatures({ rowPaginationFeature })
const columns = [{ accessorKey: 'name' }]
const data = [{ name: 'Ada' }]

function PageStatus() @{
  const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 20 })
  const table = useTable({
    features,
    columns,
    data,
    state: { pagination },
    onPaginationChange: setPagination,
  })

  <button onClick={() => table.nextPage()}>
    Page {String(table.state.pagination.pageIndex + 1)}
  </button>
}

Reactive boundaries

  • Pass both the controlled value and its callback. Octane setters accept Table's value-or-updater callbacks; a callback alone cannot feed the new value back.
  • Render <table.Subscribe> as a component. Calling it as a normal function shares the owner's compiler slots instead of creating an independent hook scope.
  • useTable stages fresh options for same-render reads. Controlled state reaches the store only from an accepted layout commit, so abandoned work cannot publish speculative values.
  • A stable atom from @tanstack/octane-store is a direct synchronous owner. Table writes reach it immediately; it takes precedence over controlled state for the same slice.
  • Keep features, columns, and data stable. Use the default selector until render cost justifies narrower subscriptions.

Read for the task

For advanced reactive boundaries, shared atoms, or detailed subscription examples, read reactivity. For construction or rendering setup, read getting-started.

API discovery

Inspect node_modules/@tanstack/octane-table/src/index.d.ts, the matching *.tsrx.d.ts sidecar, and src/types.ts. This package publishes authored source; core APIs are in installed @tanstack/table-core/dist/.

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

Vì sao đọc giá trị bằng get() không cập nhật màn hình?

Các lần đọc đó là bản chụp nhanh, nên màn hình chỉ cập nhật từ trạng thái được chọn hoặc một component subscribe được render.

Setter có nhận hàm cập nhật không?

Có. Setter của Octane nhận các callback giá trị-hoặc-cập-nhật mà bảng sử dụng.

Tôi cần truyền gì để giữ state đồng bộ?

Hãy truyền cả giá trị được điều khiển lẫn callback của nó, vì chỉ có callback thì không thể đưa giá trị mới trở lại.

Chi tiết

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

Read and control Table v9 state in octane. 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
#9818
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ự