preact/compose-with-tanstack-virtual

Virtualize TanStack Table rows and columns in Preact with TanStack Virtual.

28.3k|3.6k|Updated Oct 20, 2016
One-click install
npx skills add https://github.com/TanStack/table --skill preact-compose-with-tanstack-virtual
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: preact/compose-with-tanstack-virtual
Source: https://github.com/TanStack/table/tree/main/packages/preact-table/skills/preact/compose-with-tanstack-virtual
Command: npx skills add https://github.com/TanStack/table --skill preact-compose-with-tanstack-virtual

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves the performance bottleneck of rendering thousands of rows in a Preact datagrid by showing how to virtualize rendering while keeping TanStack Table as the source of truth.

Core Features & Use Cases

  • Row and column virtualization guidance: Pair TanStack Table with TanStack Virtual (via @tanstack/virtual-core) to render only visible items.
  • Correct integration with table features: Feed the virtualizer with table.getRowModel().rows.length so sorting/filtering/pagination/grouping are respected.
  • Variable sizing support: Use measureElement and estimateSize to prevent overlaps/gaps when row heights differ.

Quick Start

Ask your coding agent to implement row virtualization in Preact by creating a Virtualizer from @tanstack/virtual-core, using rows = table.getRowModel().rows for count, rendering virtualizer.getVirtualItems(), and positioning each row with transform: translateY(...).

Frequently Asked Questions about preact/compose-with-tanstack-virtual

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I virtualize large Preact tables without using adapter libraries?

You can virtualize large Preact tables by composing TanStack Table with TanStack Virtual's framework-agnostic Virtualizer, rendering only visible rows and columns while keeping TanStack Table as the source of truth.

What is the best way to handle variable row heights when virtualizing a Preact datagrid?

To handle variable row heights in a virtualized Preact datagrid, use the measureElement function for dynamic element measurement alongside estimateSize to prevent overlaps and gaps when row heights differ.

Does TanStack Table sorting and filtering work with row virtualization in Preact?

Yes, TanStack Table sorting and filtering work with row virtualization by feeding the virtualizer the post-feature row model length using table.getRowModel().rows.length, ensuring all features are respected.

Can I virtualize both rows and columns in a wide Preact datagrid?

Yes, you can virtualize both rows and columns in a wide Preact datagrid by configuring the Virtualizer to mount only visible items, targeting large or wide datagrid scenarios where rendering everything causes performance bottlenecks.

How to position virtual items correctly when rendering TanStack Table rows in Preact?

Position virtual items correctly by applying absolute or translated rendering for each virtual item, using CSS transform translateY values calculated from the virtualizer's getVirtualItems output to place rows accurately.