react-scroll-to-bottom
react-scroll-to-bottom copied to clipboard
How to use scrollToBottom() ?
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>
Require the same .!!
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
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.