-
-
Notifications
You must be signed in to change notification settings - Fork 341
Error: Maximum update depth exceeded #924
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
Comments
@piecyk This is very annoying bug. Help is much appreciated. |
In my case overriding the default
My suspicion: the default version of this function in the lib uses When items don't have the same dimensions: |
@dmezei If the element has a fixed height, you don’t need to override measureElement. Instead, you can just avoid passing ref={virtualizer.measureElement}. However, if explicitly overriding it with a fixed height resolved the issue for you, that suggests there might be something else affecting measurement in your setup. |
@creage can you provide a small example to reproduce the bug on your end? That would help in diagnosing the issue more effectively. |
@piecyk The example in the description. Launch Chrome DevTools there, and click on the dropdown. It will crash with error:
The way we workaround it for now is by providing custom |
Yes, the issue here is that on the first render, the elements are positioned off-screen or hidden. Without a defined height, the virtualizer will continue rendering items in the list until they fit within the viewport. One way to fix this is by checking if the element has a valid height and width. If it does, return the measured size; otherwise, fallback to the cached value: measureElement: (element, _roEntry, instance) => {
const cachedSize =
instance.measurementsCache[instance.indexFromElement(element)].size;
const rect = element.getBoundingClientRect();
if (rect.height > 0 && rect.width > 0) {
return Math.round(rect.height);
}
return cachedSize;
}, There were previous discussions about including this in the core, and overall, it should be configurable. For example, if an element in the list can be collapsed, we may want to explicitly set its size to 0. |
Describe the bug
I want to display the table in the dropdown。
I used the antd UI library
But they had a problem
Your minimal, reproducible example
https://codesandbox.io/p/devbox/infallible-smoke-8tc6d6?file=%2Fsrc%2Fmain.tsx%3A104%2C32
Steps to reproduce
click select
Don't use rowVirtualizer measureElement is normal
Expected behavior
Normal table rendering
How often does this bug happen?
None
Screenshots or Videos
No response
Platform
tanstack-virtual version
^3.12.1
TypeScript version
No response
Additional context
No response
Terms & Code of Conduct
The text was updated successfully, but these errors were encountered: