0

I have a small app in react Next.js and it is scroll-based animation fun page. Because of this I need to reset scroll position to top after reloading the page, but no matter what I try, the page change the scroll position back to the state where it was before the reload. Even I forced the page to change scroll with useEffect, setTimeout, window.scrollTo or window.scroll, clearing the timeout on return (in useEffect) and set useEffect with and without [], the position always changed back. I deleted everything from the project and left only the base Next generated and index with empty divs with height to have some page height to scroll and console.logs to see the scroll position and now it seems like the position changes to 0 after reload but immediately changes to position where I was before the reload. Why?

juliomalves
  • 42,130
  • 20
  • 150
  • 146
Viv
  • 23
  • 4

0 Answers0