What is the `sync` parameter for in the `Virtualizer.onChange` function?
Howdy! There's a parameter in the virtualizer that's not documented - the
onChange function's sync parameter
Docs: https://tanstack.com/virtual/latest/docs/api/virtualizer#onchange
Fn Signature: https://github.com/TanStack/virtual/blob/f0537588c4304fda7c231124d73cc4cbcec618a8/packages/virtual-core/src/index.ts#L250C3-L253C12
What's the sync param for? I'm willing to submit a PR to update the docs if someone can help me out here.Virtualizer | TanStack Virtual Docs
The Virtualizer class is the core of TanStack Virtual. Virtualizer instances are usually created for you by your framework adapter, but you do receive the virtualizer directly.
`tsx
GitHub
virtual/packages/virtual-core/src/index.ts at f0537588c4304fda7c231...
🤖 Headless UI for Virtualizing Large Element Lists in JS/TS, React, Solid, Vue and Svelte - TanStack/virtual
2 Replies
conscious-sapphire•2y ago
Hi, the sync param is to inform when should we force update, for example when scrolling the update should be synchronously to don't lag between offset and what is rendered, in react we have the flushSync https://react.dev/reference/react-dom/flushSync that will be used when sync is true
flushSync – React
The library for web and native user interfaces
like-goldOP•2y ago
@piecyk Thank you!
A heads up - I'm using virtual for svelte these days. Since I don't really understand how this is used very well, I won't seek to update the docs via MR.