Apply TanStack Virtual rendering to the final Preact Table row or column model through React compatibility or virtual-core. Load for adapter selection, reactive counts, scroll targets, stable keys, measurements, spacer geometry, sticky layout, sizing CSS, or overscan.
72
89%
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. Virtual is renderer composition over the final Table model, never a tableFeatures slot.
import { useRef } from 'preact/hooks'
import { useVirtualizer } from '@tanstack/react-virtual' // via preact/compat
const scrollRef = useRef<HTMLDivElement>(null)
const rows = table.getRowModel().rows
const virtualizer = useVirtualizer({
count: rows.length,
getScrollElement: () => scrollRef.current,
estimateSize: () => 36,
getItemKey: (index) => rows[index].id,
overscan: 5,
})Render a spacer of getTotalSize() and position each row from its virtual item's start.
<td style={{ width: cell.column.getSize() }}>
<table.FlexRender cell={cell} />
</td><div key={row.id} data-index={item.index} ref={virtualizer.measureElement}>
{row.id}
</div>There is no @tanstack/preact-virtual package. In the standard Preact setup that aliases React to preact/compat, use the maintained React adapter:
import { useVirtualizer } from '@tanstack/react-virtual'If the application cannot use the compat alias, integrate the Virtualizer class from @tanstack/virtual-core directly. That is a lower-level integration with application-owned lifecycle and subscriptions; do not invent Preact hooks around it.
Source: docs/framework/preact/guide/virtualization.md
Wrong:
useVirtualizer({ count: data.length, getScrollElement, estimateSize })Correct:
const rows = table.getRowModel().rows
useVirtualizer({ count: rows.length, getScrollElement, estimateSize })Raw data omits Table's current filtering, sorting, expansion, grouping, and pagination.
Source: docs/framework/preact/guide/virtualization.md
Wrong:
virtualizer.getVirtualItems().map((item) => <div>{rows[item.index].id}</div>)Correct:
virtualizer
.getVirtualItems()
.map((item) => (
<div
style={{ position: 'absolute', transform: `translateY(${item.start}px)` }}
>
{rows[item.index].id}
</div>
))Virtual computes geometry; application markup and CSS must apply it and supply the scroll container/spacer.
Source: docs/framework/preact/guide/virtualization.md
Inspect node_modules/@tanstack/preact-table/dist/index.d.ts. For rendering APIs, inspect installed node_modules/@tanstack/react-virtual/dist/ when using the standard preact/compat alias, or node_modules/@tanstack/virtual-core/dist/ for a direct integration. There is no maintained Preact-specific Virtual package or Table example; start from the Preact guide and translate the maintained React examples only through the compat setup it describes.
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.