Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70434

How to use scrollToBottom with IonContent in React

$
0
0

@gaweleczek wrote:

Hi,

I’m building a chat app and I want to make sure that the user always sees the bottom of the list of messages.

<IonContent ref={this.messagesRef}>

and then I call this function from a few places

 scrollToBottom = () => {
        if (!this.messagesRef || !this.messagesRef.current) return;
        //window.scrollTo(0, this.messagesRef.current.offsetTop)
        this.messagesRef.current.scrollToBottom();
        //scrollIntoView({ behavior: "smooth" });
        console.log("ScrollToTheBottom");
    }

But when I do this I get the following error:

TypeError: this.messagesRef.current.scrollToBottom is not a function

What am I doing wrong here?

Thanks!

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70434

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>