该技能用于把 Solid Table v9 的表格实例连接到 TanStack Devtools,便于在开发过程中检查表格状态。它建立在 @tanstack/table-core#core 与 @tanstack/table-devtools#devtools 之上。
用途 在 Solid 应用中,将 createTable 创建的表格实例注册为 Devtools 的调试目标,使表格可在 Devtools 中被查看。
主要能力 提供 tableDevtoolsPlugin 与 useTanStackTableDevtools 两个入口,用于在 Solid 组件中注册表格目标。注册钩子支持传入 { enabled } 进行条件注册。
使用方式 示例代码:
import { TanStackDevtools } from '@tanstack/solid-devtools' import { createTable, tableFeatures } from '@tanstack/solid-table' import { tableDevtoolsPlugin, useTanStackTableDevtools, } from '@tanstack/solid-table-devtools'
const features = tableFeatures({})
export function App() { const table = createTable({ key: 'users-table', features, columns: [], data: [], }) useTanStackTableDevtools(table) return }
注册需在组件的 Solid owner 内进行。可通过向钩子传入 { enabled } 实现条件注册。
常见错误
- 在 owner 之外创建注册(HIGH):错误做法是在模块作用域调用 Solid 注册钩子;正确做法是在拥有该表格的组件中调用。该钩子使用 Solid 的响应式清理来注销目标。来源:TanStack/table:packages/solid-table-devtools/src/useTanStackTableDevtools.ts。
- 缺少或复用表格 key(HIGH):错误做法是省略 options.key 或在多个已挂载表格之间共享同一个 key;正确做法是为每个活动表格分配稳定且唯一的 key。目标注册表会跳过缺少 key 的项,并替换重复的身份。来源:TanStack/table:packages/table-devtools/src/tableTarget.ts。
- 假定生产入口点处于活动状态(MEDIUM):错误做法是期望常规 Devtools 导出能在生产环境检查表格;正确做法是默认仅按开发环境指导使用,仅在明确要求时使用 /production。包索引在非开发环境会选择 no-op 实现。来源:TanStack/table:packages/solid-table-devtools/src/index.ts。
API 发现 可检查 node_modules/@tanstack/solid-table-devtools/dist/index.d.ts、useTanStackTableDevtools.d.ts 与 production.d.ts。
适用场景 适用于使用 Solid Table v9 并希望在开发阶段通过 TanStack Devtools 检查表格实例的项目。
限制 生产环境默认导出为 no-op 实现,常规 Devtools 导出不适用于生产表格检查;注册必须在 Solid owner 内进行,且每个活动表格需要唯一 key。