Create reusable Preact table infrastructure with createTableHook, useAppTable, createAppColumnHelper, shared options/features, optional component registries, App wrappers, and typed context hooks. Load for recurring conventions, scoped contexts, or prop drilling.
72
91%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
This skill builds on @tanstack/table-core#core, getting-started, and table-state. Use the app hook for repeated conventions; one-off tables should stay with useTable.
import {
createTableHook,
rowSelectionFeature,
tableFeatures,
} from '@tanstack/preact-table'
export const { createAppColumnHelper, useAppTable, useTableContext } =
createTableHook({
features: tableFeatures({ rowSelectionFeature }),
getRowId: (row: { id: string }) => row.id,
})type Person = { id: string; name: string }
const helper = createAppColumnHelper<Person>()
const columns = helper.columns([helper.accessor('name', { header: 'Name' })])function RowCount() {
const table = useTableContext()
return <output>{table.getRowModel().rows.length}</output>
}
const table = useAppTable({ data, columns })
return (
<table.AppTable>
<RowCount />
</table.AppTable>
)AppTable takes ordinary JSX children without a selector. Use function children only when a selector supplies their value:
<table.AppTable selector={(state) => state.rowSelection}>
{(rowSelection) => <output>{Object.keys(rowSelection).length}</output>}
</table.AppTable>Default contexts are module-scoped and HMR-stable; sibling tables are already isolated by their providers. Separate createTableHook calls still share those defaults, so nested providers can silently resolve a consumer to the inner table. Use fresh contexts only when different table setups are nested:
import {
createTableHook,
createTableHookContexts,
rowSelectionFeature,
tableFeatures,
} from '@tanstack/preact-table'
const features = tableFeatures({ rowSelectionFeature })
const { tableContext, cellContext, headerContext } =
createTableHookContexts<typeof features>()
export const app = createTableHook({
features,
tableContext,
cellContext,
headerContext,
})Prefer hooks returned by createTableHook because their types include registered component maps. Hooks returned directly by createTableHookContexts know only TFeatures and support modules that cannot import the completed factory.
Wrong:
const app = createTableHook({ features: tableFeatures({}) })Correct:
const table = useTable({ features, columns, data })The factory is valuable when it centralizes repeated policy, not merely another constructor name.
Source: docs/framework/preact/guide/composable-tables.md
Wrong:
return <RowCount />Correct:
return (
<table.AppTable>
<RowCount />
</table.AppTable>
)Factory context hooks require the corresponding AppTable, AppCell, or AppHeader wrapper.
Source: packages/preact-table/src/createTableHook.tsx
Wrong:
function Grid() {
const app = createTableHook({ features })
const table = app.useAppTable({ data, columns })
return (
<table.AppTable>
<div />
</table.AppTable>
)
}Correct:
const app = createTableHook({ features })
function Grid() {
const table = app.useAppTable({ data, columns })
return (
<table.AppTable>
<div />
</table.AppTable>
)
}Creating a new factory closure during render makes hook configuration and component registries unstable. Keep the factory and its bound hook identity at module scope.
Source: packages/preact-table/src/createTableHook.tsx
Inspect node_modules/@tanstack/preact-table/dist/createTableHook.d.ts and createTableHookContexts.d.ts for exact return names, provider props, registries, and scoped context types.
9e523bc
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.