divRef.current.scrollIntoView wouldn't work in mobile devices. React

32 views Asked by At

I am using divRef.current.scrollIntoView function to scroll down to certain components on the same page. It works as expected on pc but on my mobile device it wouldn't work.

const scrollVersions = () => {
    if (!versionsRef.current) return;
    versionsRef.current.scrollIntoView({ behavior: "smooth" });
  };

I have checked versionsRef.current is available and the function is being called properly. I checked for all the other problems.

I have tried scrollIntoView function in order to scroll to a component in my page, but it only works for pc and isn't working in mobile devices. I'd like to know a way so that I can scroll in both mobile and pc.

0

There are 0 answers