Can't scroll on component mount
See original GitHub issueI have the following function to scroll to the bottom of the container
const scrollChatToBottom = useCallback(() => {
animateScroll.scrollToBottom({
containerId: "event-chat-messages",
});
}, []);
And I want to execute that function on the component mount
useEffect(() => {
scrollChatToBottom();
}, [
scrollChatToBottom,
]);
But it’s not working, is there a reason to that happen?
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
React Scroll can't scroll on component mount - CodeSandbox
React Scroll can't scroll on component mount - CodeSandbox. You need to enable JavaScript to run this app.
Read more >Cannot scroll to the bottom of a div using React.js refs
Hi I am building an application where there is a list and on component mount I always want to go to the bottom...
Read more >4 Ways to Scrolling to an Element in React - Bosc Tech Labs
The most simple way is to use ref to store the reference of the element that you want to scroll to. And call...
Read more >react-scroll-to-bottom - npm
React container that will auto scroll to bottom. Latest version: 4.2.0, last published: a year ago. Start using react-scroll-to-bottom in ...
Read more >Scroll Restoration - React Router v5
Second, it would use location.key to save the window scroll position and the scroll positions of RestoredScroll components to sessionStorage . Then, when ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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
ref
orsetTimeout
- which is neither documented nor practical.If you want we could submit a PR fixing this issue.