Replies: 1 comment
-
You can use something like this const items = rowVirtualizer.getVirtualItems();
const isMountedScrollToBottomRef = useRef(false);
const scrollToBottom = useCallback(
({ behavior = "smooth" }: { behavior?: ScrollToOptions["behavior"] } = {}) => {
requestAnimationFrame(() => {
rowVirtualizer.scrollToIndex(footerIndex, {
align: "end",
behavior,
});
})
},
[rowVirtualizer, footerIndex],
);
useLayoutEffect(() => {
if (!isMountedScrollToBottomRef.current && items.length > 0) {
isMountedScrollToBottomRef.current = true;
scrollToBottom({ behavior: "auto" });
}
}, [items, scrollToBottom]); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using useVirtualizer, dynamic mode
Like a chat message list, i want to start at the bottom of the scroller
I currently do this, but the result is not at the bottom, i guess i shoud do this when the measument is end, but there isn't a event
useEffect(() => { rowVirtualizer.scrollToIndex(data.length - 1) }, [])
Beta Was this translation helpful? Give feedback.
All reactions