react-scroll-to-bottom icon indicating copy to clipboard operation
react-scroll-to-bottom copied to clipboard

How to use scrollToBottom() ?

Open Steffi3rd opened this issue 5 years ago • 3 comments

I would like to scroll at the bottom when I click on Submit Button.

It seems you have a function scrollToBottom() which do that job but I don't know how.

import ScrollToBottom from 'react-scroll-to-bottom';
<CommentZone>
       <ScrollToBottom animating={false} checkInterval={17}>
            <Comments>
               Comments<br />
               Comments<br />
               BOTTOM BABY<br />
             </Comments>
        </ScrollToBottom>
       <WriteComment>
             <Textarea maxRows={10} autoFocus />
             <Button onClick={() => scrollToBottom()}>Envoyer</Button>
        </WriteComment>
</CommentZone>

Steffi3rd avatar Apr 04 '19 10:04 Steffi3rd

Require the same .!!

ashiquemohammed avatar Apr 05 '19 06:04 ashiquemohammed

Just try this one with browser scrollIntoView():

<div refs="scroll"></div>

scroll(){
      const element = this.refs.scroll;
      element.scrollIntoView(false,{behavior: "smooth",block: "end"});
 }

componentDidUpdate(){
      this.scroll();
}

link: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView

Asinox avatar Apr 18 '19 14:04 Asinox

I'm looking for a similar answer. I'd like to use FunctionContext methods, but can't find any explanation or example of how to do this.

brspurri avatar Jul 29 '19 23:07 brspurri