Hi,
I’ve checked the documentation on the ionic react site here and can’t see a method to call for an IonList to scroll to bottom.
Anyone know if this is possible please?
Thanks,
Stephen
Hi,
I’ve checked the documentation on the ionic react site here and can’t see a method to call for an IonList to scroll to bottom.
Anyone know if this is possible please?
Thanks,
Stephen
Hi @supaevensteven, I have the same issue, still I haven’t got any success. I have tried this:-
getContent() {
return document.querySelector(‘ion-content’);
}
scrollToBottom = () => {
this.getContent().scrollToBottom(500);
}
It’s showing me error, "Object is possibly ‘null’. "
If you got any solution please let me know.
const scrollToBottom = () => {
let list = document.querySelector("ion-content");
return list && list.scrollToBottom();
};
Thank you @aaronksaunders, it’s worked.
In my case, in the docuemnt
, there were two <ion-content>
.
so use below code.
export const scrollToBottom = (query = 'ion-content') => {
const list: NodeListOf<HTMLIonContentElement> = document.querySelectorAll(query)
if (list.length) {
const content: HTMLIonContentElement = list[list.length - 1]
content.scrollToBottom()
}
}
Why not use useRef
?