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

table-state

できること

ページ番号などのテーブルの設定を、Vueのrefで管理し、テンプレートで読む方法を説明します。テーブルとページを同期させたいVue開発者向けです。

使う場面

  • ✓Vueのテンプレートで現在のページなど、テーブルの設定を表示する必要があるとき。
  • ✓テーブルのページ送りをrefや算出値につなぐ必要があるとき。
  • ✓スクリプト内で一度読んだテーブルの値が、変更後も更新されないとき。

スキルのリンク

https://github.com/TanStack/table/blob/main/packages/vue-table/skills/table-state/SKILL.md

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

使い方

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

貼り付け用メッセージ

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

AIへの頼み方の例

“次へをクリックしたとき、Vueテーブルのページ番号が画面で更新されるようにする方法を教えてください。”

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

仕組み

ページ送りの設定をrefで保持し、更新用コールバックと一緒に算出状態としてテーブルに渡し、テンプレートで読む方法を示します。

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

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

Vue table state

Before starting, run intent load @tanstack/table-core#table-state for shared ownership, initialization, updates, and resets.

Read reactive state

Vue-backed atom reads track dependencies inside templates, computed, watch, or a render boundary. const page = table.atoms.pagination.get() outside tracking captures a snapshot. Keep reactive option inputs as refs, computed values, or getters; passing .value once breaks later synchronization.

table.Subscribe is deprecated. Read table APIs or atoms directly inside templates, render functions, computed getters, or watcher sources. Use a child component when reads need a separate component render boundary.

Control a slice

Keep features and columns stable. Preserve both the reactive value and its matching callback:

import { computed, ref } from 'vue'
import {
  rowPaginationFeature,
  tableFeatures,
  useTable,
  type PaginationState,
  type Updater,
} from '@tanstack/vue-table'

const features = tableFeatures({ rowPaginationFeature })
const columns = [{ accessorKey: 'name' }]
const data = ref([{ name: 'Ada' }])
const pagination = ref<PaginationState>({ pageIndex: 0, pageSize: 20 })
const state = computed(() => ({ pagination: pagination.value }))
const table = useTable({
  features,
  columns,
  data,
  state,
  onPaginationChange: (next: Updater<PaginationState>) => {
    pagination.value =
      typeof next === 'function' ? next(pagination.value) : next
  },
})
const pageSize = computed(() => table.atoms.pagination.get().pageSize)

Assign the resolved updater result to the ref. For shared atom ownership, use a stable @tanstack/vue-store atom in atoms.<slice> instead of mirroring the same slice in controlled refs.

For computed-state synchronization failures, updater mistakes, or render boundaries, 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/vue-table/dist/useTable.d.ts and reactivity.d.ts; inspect the matching core feature declarations for the controlled slice.

よくある質問

スクリプトで一度読んだ値が更新されないのはなぜですか?

追跡の外での読み取りはスナップショットになり、そのスナップショットは後から更新されないからです。

テーブルには.valueを渡すべきですか?

いいえ。.valueを一度渡すと後の同期が壊れるため、リアクティブな入力はrefや算出値、ゲッターのままにするよう、このスキルは説明しています。

table.Subscribeはまだ使いますか?

非推奨です。テンプレートでテーブルのAPIやatomsを直接読むよう勧めています。

詳細

作者による元の説明

Read and control Table v9 state in vue. Use for tracked reads, subscriptions, controlled slices, and framework-specific reactive boundaries.

repo: TanStack/table

人気

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

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

0

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

コメント

  • …

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

似ているスキル