跳到正文
Skillpedia
网站与界面(前端)29k · #9823

devtools

它能做什么

这项技能展示如何把 React 表格注册到 TanStack Devtools 面板中,使开发者在构建时能检查它们。内容涵盖设置、必需的键和清理。

适用场景

  • ✓当 React 表格没有出现在开发者工具面板中,你需要修复其注册的时候。
  • ✓当你想在开发模式下运行应用时检查 React 表格的状态的时候。
  • ✓当你需要开发者工具钩子遵循 React 规则,而不是被有条件地调用的时候。

技能链接

https://github.com/TanStack/table/blob/main/packages/react-table-devtools/skills/devtools/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/TanStack/table/blob/main/packages/react-table-devtools/skills/devtools/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“为什么我的 React 表格没有显示在 TanStack 开发者工具面板中?”

每周 5 个新技能,1 分钟读完。

工作原理

它解释如何为表格提供唯一的键,在创建表格后立即调用注册钩子,并在应用根部附近添加一个开发者工具宿主。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

This skill builds on @tanstack/table-core#core and @tanstack/table-devtools#devtools.

Setup

import { TanStackDevtools } from '@tanstack/react-devtools'
import { useTable, tableFeatures } from '@tanstack/react-table'
import {
  tableDevtoolsPlugin,
  useTanStackTableDevtools,
} from '@tanstack/react-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 useTanStackTableDevtools(table, { enabled }) immediately after creating the table. Mount one TanStackDevtools host with tableDevtoolsPlugin() near the application root.

Common Mistakes

HIGH Hook receives a keyless table

Wrong: create the table without key and expect the hook to infer a name.

Correct: set a unique key in table options before calling the hook.

Core target registration skips keyless tables.

Source: TanStack/table:docs/devtools.md

HIGH Hook called conditionally

Wrong: call useTanStackTableDevtools only inside an if branch.

Correct: call it every render and pass { enabled: condition }.

The hook owns React effect registration and cleanup.

Source: TanStack/table:packages/react-table-devtools/src/useTanStackTableDevtools.ts

MEDIUM Default import expected in production

Wrong: expect the normal hook/plugin/panel to inspect production tables.

Correct: keep normal guidance development-only; use the /production entrypoint only when explicitly required.

The default index selects no-op implementations outside development.

Source: TanStack/table:packages/react-table-devtools/src/index.ts

API Discovery

Inspect node_modules/@tanstack/react-table-devtools/dist/index.d.ts and useTanStackTableDevtools.d.ts for the installed lifecycle API.

常见问题

为什么我的表格被开发者工具跳过了?

没有键的表格会被跳过,因此这项技能说明应先设置唯一的键,再调用该钩子。

我可以开启或关闭开发者工具的注册吗?

可以,向钩子传入 enabled 选项,而不是只在 if 分支中调用它。

开发者工具宿主应该放在哪里?

放在应用根部附近,只添加一次,并在其中加入表格开发者工具插件。

详情

作者的原始描述

Connect React Table v9 instances to Devtools with tableDevtoolsPlugin and useTanStackTableDevtools. Load for missing Table panels, registration lifecycle, required options.key, enabled state, or development versus explicit production exports.

repo: TanStack/table

热度

GitHub 星标
29k
排名
#9823
许可证
MIT
更新时间
2026/10/21

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能