question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't scroll on component mount

See original GitHub issue

I 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:open
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
fisshycommented, Jun 8, 2020

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.

2reactions
pedro-lbcommented, Jun 8, 2020

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 or setTimeout - which is neither documented nor practical.

If you want we could submit a PR fixing this issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found