-
-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React Compiler: useVirtual results are cached at their initial values #736
Comments
Similar thing happens if the component is wrapped in |
Specifying |
got same problem, very annoying when using react-compiler. My workaround was to save an instance of virtualizer as state when the onChange function is saved, and use that instance in my component instead of the instance returned by the hook.
any official solution or hint? |
Describe the bug
An usage of
useVirtual
gets compiled by React Compiler into something like this:Since the virtualizer ref never changes, the virtual items never get updated.
Not sure if this should be a Tanstack Virtual issue or React Compiler needs to apply less assumptions when caching values, but thought that would be good to flag the problem here.
Wrapping
useVirtual
into something like this fixes the issue:Your minimal, reproducible example
https://codesandbox.io/p/devbox/runtime-dew-9rlvm7
Steps to reproduce
Expected behavior
The UI should be the same as https://tanstack.com/virtual/latest/docs/framework/react/examples/fixed
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
tanstack-virtual version
3.5.0
TypeScript version
No response
Additional context
No response
Terms & Code of Conduct
The text was updated successfully, but these errors were encountered: