feat(react-virtual): add useFlushSync option #1100
main fromrefs/pull/1100/head·merged by piecyk 🎯 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
View your CI Pipeline Execution ↗ for commit 0c8a49949d8d7481d2a38fefd955709fb927e7e0
Command Status Duration Result nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded 8s View ↗ nx run-many --target=build --exclude=examples/**✅ Succeeded 16s View ↗
☁️ Nx Cloud last updated this comment at
2025-12-30 07:58:22UTCMore templates
- @tanstack/virtual-example-angular-dynamic
- @tanstack/virtual-example-angular-fixed
- @tanstack/virtual-example-angular-infinite-scroll
- @tanstack/virtual-example-angular-padding
- @tanstack/virtual-example-angular-smooth-scroll
- @tanstack/virtual-example-angular-sticky
- @tanstack/virtual-example-angular-table
- @tanstack/virtual-example-angular-variable
- @tanstack/virtual-example-angular-window
- tanstack-lit-virtual-example-dynamic
- tanstack-lit-virtual-example-fixed
- tanstack-react-virtual-example-dynamic
- tanstack-react-virtual-example-fixed
- tanstack-react-virtual-example-infinite-scroll
- tanstack-react-virtual-example-padding
- tanstack-react-virtual-example-scroll-padding
- tanstack-react-virtual-example-smooth-scroll
- tanstack-react-virtual-example-sticky
- tanstack-react-virtual-example-table
- tanstack-react-virtual-example-variable
- tanstack-react-virtual-example-window
- tanstack-svelte-virtual-example-dynamic
- tanstack-svelte-virtual-example-fixed
- tanstack-svelte-virtual-example-infinite-scroll
- tanstack-svelte-virtual-example-smooth-scroll
- tanstack-svelte-virtual-example-sticky
- tanstack-svelte-virtual-example-table
- tanstack-vue-virtual-example-dynamic
- tanstack-vue-virtual-example-fixed
- tanstack-vue-virtual-example-infinite-scroll
- tanstack-vue-virtual-example-padding
- tanstack-vue-virtual-example-scroll-padding
- tanstack-vue-virtual-example-smooth-scroll
- tanstack-vue-virtual-example-sticky
- tanstack-vue-virtual-example-table
- tanstack-vue-virtual-example-variable
@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@1100commit:
0c8a499channyeintun(GitHub profile, opens in a new tab) approved these changes
Agreed — the solution is pretty straightforward and the implementation is clean. Nice work.
piecyk merged this1686256
piecyk closed this
Sign in to join this conversation.
🦋 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
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