I'm trying to implement a click to scroll function in my react app. I tried using react-scroll library, window.scrollIntoView, and using window.scrollTo with a ref. These didn't work with my app having an overflow, so I'm forced to remove it to get it to work.
.App {
height: 100vh;
overflow-y: scroll; // removing this makes click to scroll work
}
how I used window.scrollTo:
const scrollSection = useRef(null);
const goToSection = () => {
window.scrollTO({
top: scrollSection.current.offsetTop,
behavior: "smooth"
});
and react-scroll:
<Link to="firstSection" spy={true} smooth={true}>
<li></li>
</Link>
Is there a way to get this working with overflow, since I'd like to keep the overflow styling if possible.