Open adnankarim opened 3 years ago
I don't think this library will be updated ever again.
Here's my solution derived from this SO answer.
import React, { useEffect, useState } from 'react';
import PerfectScrollbar from 'react-perfect-scrollbar';
const Messages = () => {
const [scrollEl, setScrollEl] = useState();
useEffect(() => {
if (scrollEl) {
// Set the scroll position to the bottom
scrollEl.scrollTop = scrollEl.scrollHeight;
}
}, [scrollEl]);
return (
<PerfectScrollbar containerRef={setScrollEl}>
{/* ............. */}
</PerfectScrollbar>
);
};
export default Messages;
Scroll should start from bottom as default instead of top in react hooks components