devtools
它能做什么
这项技能展示如何把 Preact 表格注册到 TanStack Devtools 面板中,使开发者在构建时能检查它们。适合希望在开发时查看表格状态的 Preact 开发者。
适用场景
- ✓当你想在开发模式下运行应用时检查 Preact 表格的状态的时候。
- ✓当某个表格没有出现在开发者工具面板中,你需要检查其注册情况的时候。
- ✓当 React 和 Preact 包混用,开发者工具无法正确连接的时候。
技能链接
https://github.com/TanStack/table/blob/main/packages/preact-table-devtools/skills/devtools/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的 Preact 表格没有出现在 TanStack 开发者工具面板中。应该如何连接?”
每周 5 个新技能,1 分钟读完。
工作原理
它解释如何用唯一的键创建表格,用 Preact 钩子注册它,并在应用根部附近添加一次开发者工具插件。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
This skill builds on @tanstack/table-core#core and @tanstack/table-devtools#devtools.
Setup
import { TanStackDevtools } from '@tanstack/preact-devtools'
import { useTable, tableFeatures } from '@tanstack/preact-table'
import {
tableDevtoolsPlugin,
useTanStackTableDevtools,
} from '@tanstack/preact-table-devtools'
const features = tableFeatures({})
const columns = [{ accessorKey: 'id' }]
const data: Array<{ id: string }> = []
export function App() {
const table = useTable({
key: 'users-table',
features,
columns,
data,
})
useTanStackTableDevtools(table)
return <TanStackDevtools plugins={[tableDevtoolsPlugin()]} />
}
Hooks and Components
Use the native Preact packages throughout. Pass { enabled } rather than conditionally calling the registration hook.
Common Mistakes
HIGH React Devtools package mixed into Preact
Wrong: import the hook from @tanstack/react-table-devtools through compat.
Correct: use @tanstack/preact-table-devtools with @tanstack/preact-devtools.
The native adapter owns Preact effect lifecycle and plugin types.
Source: TanStack/table:docs/devtools.md
HIGH Missing or duplicate key
Wrong: omit key or reuse users-table for multiple mounted tables.
Correct: give each live table one stable unique key.
Keyless registration is skipped; duplicate keys replace targets.
Source: TanStack/table:packages/table-devtools/src/tableTarget.ts
MEDIUM Production no-op mistaken for failure
Wrong: expect the default entrypoint to stay active in a production bundle.
Correct: keep Devtools development-only unless an explicit production import is required.
The default index deliberately selects no-op implementations outside development.
Source: TanStack/table:packages/preact-table-devtools/src/index.ts
API Discovery
Inspect node_modules/@tanstack/preact-table-devtools/dist/index.d.ts and useTanStackTableDevtools.d.ts; do not copy React adapter imports.
常见问题
为什么每个表格都需要一个键?
没有键的表格会被跳过,而两个键相同的表格会在面板中互相替换。
我可以开启或关闭注册吗?
可以,该钩子接受 enabled 选项,因此无需删除调用即可关闭。
在 Preact 应用中应该使用 React 的开发者工具包吗?
不应该,这项技能说明应使用原生 Preact 包,而不是通过兼容别名导入 React 包。
详情
作者的原始描述
Connect native Preact Table v9 instances to Devtools with tableDevtoolsPlugin and useTanStackTableDevtools. Load for React-package mixups, missing targets, required options.key, enabled state, cleanup, or development gating.
repo: TanStack/table
热度
- GitHub 星标
- 29k
- 排名
- #9819
- 许可证
- 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 设置、模板渲染和行数据的更新。