Skip to content

feat: add e2e and perf tests for useExperimentalDOMVirtualizer with hook injection#1141

Draft
piecyk wants to merge 2 commits intoTanStack:mainfrom
piecyk:feat/useExperimentalVirtualizer
Draft

feat: add e2e and perf tests for useExperimentalDOMVirtualizer with hook injection#1141
piecyk wants to merge 2 commits intoTanStack:mainfrom
piecyk:feat/useExperimentalVirtualizer

Conversation

@piecyk
Copy link
Collaborator

@piecyk piecyk commented Mar 9, 2026

🎯 Changes

Performance Comparison: useVirtualizer vs useExperimentalDOMVirtualizer

All 32 tests passed (34.7s).

Metric useVirtualizer useExperimentalVirtualizer Difference
Initial render 30.1ms, 3 renders 26.3ms, 3 renders ~13% faster
Scroll 200×100px 60.0 fps, 407 renders 59.9 fps, 215 renders 47% fewer renders
Scroll 500×20px 60.1 fps, 410 renders 60.1 fps, 264 renders 36% fewer renders
scrollToIndex(5000) 4 renders 5 renders similar
Round-trip (9999→0) 6 renders 6 renders identical

Key Takeaways

  • The experimental hook cuts React render count nearly in half during continuous scrolling while maintaining the same 60fps.
  • Both hooks achieve identical frame rates — the render savings translate to lower CPU usage and better battery life.
  • The difference will be more pronounced on slower devices or with heavier item components.

How it works

useExperimentalVirtualizer bypasses React re-renders for item positioning by directly mutating DOM styles (transform, height) during scroll. It only triggers a React re-render when the visible range or isScrolling state changes, which happens far less frequently than per-frame position updates.

Test setup

  • 10,000 items with random heights (25–100px)
  • Scroll container: 400px height, contain: strict, overflowAnchor: none
  • Playwright + Chromium, production build

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

@changeset-bot
Copy link

changeset-bot bot commented Mar 9, 2026

⚠️ No Changeset found

Latest commit: 1cd67a0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@nx-cloud
Copy link

nx-cloud bot commented Mar 9, 2026

View your CI Pipeline Execution ↗ for commit 1cd67a0

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 9s View ↗
nx run-many --target=build --exclude=examples/** ✅ Succeeded 16s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-10 04:06:40 UTC

@piecyk piecyk force-pushed the feat/useExperimentalVirtualizer branch from 5748d9c to 9d1b31c Compare March 9, 2026 22:05
@piecyk piecyk changed the title feat: add e2e and perf tests for useExperimentalVirtualizer with hook injection feat: add e2e and perf tests for useExperimentalDOMVirtualizer with hook injection Mar 9, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 9, 2026

More templates

@tanstack/angular-virtual

npm i https://pkg.pr.new/@tanstack/angular-virtual@1141

@tanstack/lit-virtual

npm i https://pkg.pr.new/@tanstack/lit-virtual@1141

@tanstack/react-virtual

npm i https://pkg.pr.new/@tanstack/react-virtual@1141

@tanstack/solid-virtual

npm i https://pkg.pr.new/@tanstack/solid-virtual@1141

@tanstack/svelte-virtual

npm i https://pkg.pr.new/@tanstack/svelte-virtual@1141

@tanstack/virtual-core

npm i https://pkg.pr.new/@tanstack/virtual-core@1141

@tanstack/vue-virtual

npm i https://pkg.pr.new/@tanstack/vue-virtual@1141

commit: 9b1efe8

@piecyk piecyk force-pushed the feat/useExperimentalVirtualizer branch from 95b74d4 to 525ee89 Compare March 10, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant