table-state
它能做什么
这项技能解释表格设置,例如当前页,在 Solid 应用中如何工作。适合需要表格和自己的组件对同一组值作出响应的 Solid 开发者。
适用场景
- ✓当 Solid 模板必须显示当前页或其他表格设置的时候。
- ✓当你需要把表格设置连接到 Solid 信号或 memo 的时候。
- ✓当组件主体中读取的值在表格变化后没有更新的时候。
技能链接
https://github.com/TanStack/table/blob/main/packages/solid-table/skills/table-state/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“如何在按钮标签中显示我的 Solid 表格的当前页码,并使其保持最新?”
每周 5 个新技能,1 分钟读完。
工作原理
它展示如何在 JSX、memo 或副作用中读取表格的原子值,因为 Solid 会在这些位置进行追踪;并展示如何用接受更新函数的设置函数传入受控信号。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Solid table state
Before starting, run intent load @tanstack/table-core#table-state for shared ownership, initialization, updates, and resets.
Read reactive state
The adapter backs table atoms with Solid signals and memos. Read table.atoms.<slice>.get() inside JSX, createMemo, createEffect, or another tracked scope. A value captured once outside tracking is only a snapshot. Solid has no React-style selected table.state.
table.Subscribe is deprecated and adds no subscription or tracking scope. Read table.atoms directly inside JSX, memos, or effects. Component bodies are untracked; keep reads inside tracked scopes. Track the required atoms instead of adding whole-store forced rerenders.
Control a slice
Keep features and columns stable. Expose changing data and controlled state through getters. Solid setters already accept Table's raw values and updater functions:
import { createMemo, createSignal } from 'solid-js'
import {
createTable,
rowPaginationFeature,
tableFeatures,
type PaginationState,
} from '@tanstack/solid-table'
const features = tableFeatures({ rowPaginationFeature })
const columns = [{ accessorKey: 'name' }]
export function PageControl() {
const [data] = createSignal([{ name: 'Ada' }])
const [pagination, setPagination] = createSignal<PaginationState>({
pageIndex: 0,
pageSize: 20,
})
const table = createTable({
features,
columns,
get data() {
return data()
},
state: {
get pagination() {
return pagination()
},
},
onPaginationChange: setPagination,
})
const pageSize = createMemo(() => table.atoms.pagination.get().pageSize)
return (
<button onClick={() => table.setPageSize(50)}>
{pageSize()} rows per page
</button>
)
}
When wrapping a setter to add a side effect, resolve both updater forms before storing the result. For shared atom ownership, use createAtom from @tanstack/solid-store and pass it in atoms.<slice>.
For external atoms, custom updater wrappers, or tracking failures, 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/solid-table/dist/createTable.d.ts and reactivity.d.ts; inspect @tanstack/solid-store declarations for external atoms.
常见问题
为什么在组件主体中读取的值不会更新?
Solid 不会追踪组件主体中的读取,因此那里的值只是一个快照。
表格的 Subscribe 组件还需要吗?
不需要,这项技能说明它已被弃用,直接在 JSX、memo 或副作用中读取表格的原子值即可。
设置函数可以接受更新函数吗?
可以,Solid 的设置函数既接受原始值,也接受更新函数,这正是表格所期望的。
详情
作者的原始描述
Read and control Table v9 state in solid. Use for tracked reads, subscriptions, controlled slices, and framework-specific reactive boundaries.
repo: TanStack/table
热度
- GitHub 星标
- 29k
- 排名
- #9830
- 许可证
- MIT
- 更新时间
- 2026/10/21
评论
- …
同一仓库的更多技能
getting-started
29k教你的智能体如何在 Alpine.js 中使用 TanStack Table 构建并显示数据表格,涵盖设置、响应式数据和渲染行。
table-state
29k教你的智能体如何在 Alpine.js 中读取和控制表格状态,例如当前页码,使状态变化时屏幕能够更新。
devtools
29k教你的智能体如何把 Angular 表格注册到 TanStack Devtools 面板中,使开发者在构建应用时能检查每个表格。
getting-started
29k教你的智能体如何在 Angular 中创建并显示 TanStack 表格,涵盖 injectTable 设置、模板渲染和行数据的更新。