-
-
Notifications
You must be signed in to change notification settings - Fork 271
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
How to force a rerender of useVirtualizer? #528
Comments
Hi @ocodista to read height out of box using the resize observer please attach additional props on item, like
https://codesandbox.io/p/sandbox/dynamic-height-change-height-on-click-forked-gq33ld |
Jesus, this is great, thank you!!! |
|
I'm having a similar issue, and in my case setting I understand why, as changing the However, for insert/remove animations to work, each row's key must be tied to a unique identifier in the underlying data, right? This is the only way for React to track that row N is now at, say, N+10 after adding 10 rows above it, so row N remains in the DOM and smoothly animates to a new position. I hope that makes sense. Is there a way to trigger re-renders that doesn't involve resetting keys? |
I found a relatively straightforward solution to my above comment shortly after posting it -- listening to
I can't notice or detect any degradation in performance, but who knows. As far as I can tell, this makes |
hmm if you don't use arrow it on ref, just pass measureElement then it should fire only once, https://react.dev/reference/react-dom/components/common#ref-callback
|
Describe the bug
I need to change the height of a list item when the user clicks on it.
It needs to be an InfiniteScroll with dynamic height.
I was able to update the height of the element clicked but the other ones (after them) are not re-rendered, causing them to stack.
I created a sandbox with the reproduceable bug, you only need to click in any of the items to see it.
https://codesandbox.io/p/sandbox/optimistic-edison-jebzqk?file=%2Fsrc%2Fmain.tsx&selection=%5B%7B%22endColumn%22%3A40%2C%22endLineNumber%22%3A72%2C%22startColumn%22%3A40%2C%22startLineNumber%22%3A72%7D%5D
Your minimal, reproducible example
https://codesandbox.io/p/sandbox/optimistic-edison-jebzqk?selection=%5B%7B%22endColumn%22%3A1%2C%22endLineNumber%22%3A109%2C%22startColumn%22%3A1%2C%22startLineNumber%22%3A109%7D%5D&file=%2Fsrc%2Fmain.tsx
Steps to reproduce
Expected behavior
How often does this bug happen?
Every time
Screenshots or Videos
Platform
tanstack-virtual version
3.0.0-beta.48
TypeScript version
No response
Additional context
No response
Terms & Code of Conduct
The text was updated successfully, but these errors were encountered: