How to set scrollbar to bottom for ScrollArea #4193
Unanswered
hasnainadil
asked this question in
Q&A
Replies: 0 comments
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 a bit new to react and nextjs development. I'm using nextjs14 for a dummy chatapp. I was trying to set the scrollbar to bottom when I enter the page so I tried this
useEffect(() => {
{chatMessages.map((message, index) => (// Scroll to bottom of the scroll area
if (scrollAreaRef.current) {
console.log("scrolling to bottom");
scrollAreaRef.current.scrollTop = scrollAreaRef.current.scrollHeight;
console.log(scrollAreaRef.current.scrollHeight); //I'm getting 537 here
console.log(scrollAreaRef.current.scrollTop); //I'm still getting 0 here height can't be set
}
}, [chatMessages, openedChat]);
{message}
this doesn't work at all but usual div works just fine
regular div code:
{message}
Beta Was this translation helpful? Give feedback.
All reactions