Skip to content
Source
Sign inSign up
TanStack/virtual

feat(react-virtual): add useFlushSync option #1100

Mergedpiecykmerged 3 commits intomain fromrefs/pull/1100/headmerged by piecyk

piecykcommented

🎯 Changes

Adds a React-specific configuration flag (useFlushSync) to @tanstack/react-virtual to control whether flushSync is used for synchronous scroll correction during measurement.

flushSync is intentionally used to limit visible whitespace during fast scrolling with dynamically measured items. In React 19 this triggers a warning when called from useLayoutEffect, but the warning itself does not affect correctness in this case.

Instead of changing the default behavior to silence the warning, this PR makes the behavior explicit and opt-out:

useFlushSync: true (default) preserves existing scrolling behavior
useFlushSync: false avoids calling flushSync, at the cost of potentially increased whitespace during fast scrolling

This keeps backward compatibility while allowing React 19 users to opt out if desired.

✅ 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).
    1. changeset-bot[bot](GitHub profile, opens in a new tab)commented

      🦋 Changeset detected

      Latest commit: 0c8a49949d8d7481d2a38fefd955709fb927e7e0

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 1 package
      NameType
      @tanstack/react-virtualPatch

      Not sure what this means? Click here to learn what changesets are.

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

    2. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 0c8a49949d8d7481d2a38fefd955709fb927e7e0

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded8sView ↗
      nx run-many --target=build --exclude=examples/**✅ Succeeded16sView ↗

      ☁️ Nx Cloud last updated this comment at 2025-12-30 07:58:22 UTC

    3. pkg-pr-new[bot](GitHub profile, opens in a new tab)commented
      More templates

      @tanstack/angular-virtual

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

      @tanstack/lit-virtual

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

      @tanstack/react-virtual

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

      @tanstack/solid-virtual

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

      @tanstack/svelte-virtual

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

      @tanstack/virtual-core

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

      @tanstack/vue-virtual

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

      commit: 0c8a499

    4. channyeintun(GitHub profile, opens in a new tab) approved these changes

      Agreed — the solution is pretty straightforward and the implementation is clean. Nice work.

    5. piecyk merged this1686256

    6. piecyk closed this

Sign in to join this conversation.