react/compose-with-tanstack-virtual

Virtualize TanStack Table rows with useVirtualizer and getVirtualItems.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill prevents browser freezes when TanStack Table renders extremely large datasets by virtualizing which rows (and optionally columns) are actually mounted in the DOM.

Core Features & Use Cases

  • Row virtualization for large datasets: Uses useVirtualizer with getVirtualItems() so only visible rows render, avoiding rendering tens of thousands of <tr> elements.
  • Deepest-component virtualizer placement: Keeps useVirtualizer in the most deeply nested component (e.g., a TableBody) to preserve scroll position and avoid remeasurement churn.
  • Column virtualization + padding placeholders: Supports horizontal: true with left/right placeholder cells to keep scroll width and alignment correct.
  • Infinite scroll integration: Combines virtualization with useInfiniteQuery and requires server-side sorting via manualSorting: true to avoid row order scrambling.

Quick Start

Use the skill to implement row virtualization by placing useVirtualizer inside your TableBody, using rows.length for count, rendering only rowVirtualizer.getVirtualItems(), and positioning each virtual row with transform: translateY(virtualRow.start)px while making the <tbody> a grid with a fixed total height.

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

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

FAQPage Schema
How do I render massive React datasets without crashing the browser?

Row virtualization with TanStack Table prevents browser freezes by using `useVirtualizer` to mount only visible rows, avoiding rendering tens of thousands of `<tr>` elements simultaneously. You position rows using `transform: translateY` inside a grid-based `<tbody>`.

Where should I place useVirtualizer when building a TanStack Table?

Place `useVirtualizer` in the deepest table body component, such as a `TableBody`. This specific placement preserves scroll position and avoids remeasurement churn during high-performance scrolling.

Does virtualization work with infinite scroll and server-side sorting?

Yes, infinite scroll integration combines virtualization with `useInfiniteQuery` and requires `manualSorting: true` for server-side sorting, which prevents row order scrambling during paginated data fetching.

Can I virtualize columns horizontally in a React datagrid?

Yes, TanStack Virtual supports horizontal virtualization by enabling `horizontal: true` with left and right padding placeholder cells, keeping scroll width and alignment correct for wide tables.

Why does my virtualized table lose scroll position on remeasurement?

Scroll position loss happens when `useVirtualizer` is placed in a parent component. Moving it to the most deeply nested table body component prevents remeasurement churn and stabilizes scrolling.