-
-
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
render multipletimes when estimateSize is not the same as real dom size #544
Comments
help me please.crying |
@fallenleavesguy You can try taking const [lastItem, setLastItem] = React.useState([...rowVirtualizer.getVirtualItems()].reverse());
React.useEffect(() => {
const [lastItem] = [...rowVirtualizer.getVirtualItems()].reverse();
setLastItem(lastItem);
}, [rowVirtualizer.getVirtualItems()]);
React.useEffect(() => {
if (!lastItem) {
return;
}
if (
lastItem.index >= allRows.length &&
hasNextPage &&
!isFetchingNextPage
) {
console.log("request fetching in VirtualList");
fetchNextPage();
}
}, [
hasNextPage,
fetchNextPage,
allRows.length,
isFetchingNextPage,
lastItem,
]); |
@ZakisM Thank you. Yes.Works well but why.Could you tell me. |
I see.the last item object didn't change in the same frame.thanks |
to
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
If the estimateSize is not equal to the actual height of the DOM nodes, it will return two different items (rowVirtualizer.getVirtualItems()) in the same frame, causing two requests for loading more data within the same frame. However, react-query has not had time to update the isFetchingNextPage variable.
Your minimal, reproducible example
https://codesandbox.io/p/sandbox/render-twice-and-request-twice-o93msp
Steps to reproduce
Expected behavior
return the same items or tell me how to awoid it
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
all platforms
tanstack-virtual version
4.0.0-beta.54
TypeScript version
No response
Additional context
No response
Terms & Code of Conduct
The text was updated successfully, but these errors were encountered: