-
Notifications
You must be signed in to change notification settings - Fork 436
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
Can't scroll on component mount #430
Comments
Should most likely work. Could you provide a Plunkr/Codepen demonstrating the issue? |
I'm not really sure why it doesn't work on initial mount. but providing a ref solves it.
|
Maybe the element isn't declared in the tree yet. |
Yepp, could be. |
Hey there, @fisshy! I don't think this issue is solved. Should be resolved internally within the lib - otherwise everywhere we use this we'll have to add a If you want we could submit a PR fixing this issue. |
Yes, I was a bit fast to close it, sorry. You both are more then welcome to make a PR. Would be cool to make something like “useScroll” which resolves after the three is updated. |
@fisshy import { useEffect, useRef } from "react";
import { scroller } from "react-scroll";
const containerRef = useRef(null);
useEffect(() => {
if (containerRef && containerRef.current) {
scroller.scrollTo("event-chat-messages", {});
}, [containerRef.current]);
<div ref={containerRef}>
<div id="event-chat-messages"></div>
</div> |
@fisshy |
I have the following function to scroll to the bottom of the container
And I want to execute that function on the component mount
But it's not working, is there a reason to that happen?
The text was updated successfully, but these errors were encountered: