How can i autoscroll to the very top each time you enter a new route?
Answered
Sun bear posted this in #help-forum
Sun bearOP
Each time i enter a different route, the scroll maintains the position it had on the previous page.
I've tried scroll={} to try to understand the behavior but i can't figure it out.
I've also tried
I've tried scroll={} to try to understand the behavior but i can't figure it out.
I've also tried
useEffect(() => {
window.scrollTo(0, 0)
}, [pathname])using a scroller component to wrap my layoutAnswered by B33fb0n3
when you using router.push or similar in nextjs, then nextjs automatically does that for you. No need nothing else to archive that
5 Replies
@Sun bear Each time i enter a different route, the scroll maintains the position it had on the previous page.
I've tried scroll={} to try to understand the behavior but i can't figure it out.
I've also tried
useEffect(() => {
window.scrollTo(0, 0)
}, [pathname])using a scroller component to wrap my layout
when you using router.push or similar in nextjs, then nextjs automatically does that for you. No need nothing else to archive that
Answer
@Sun bear solved?
@B33fb0n3 <@307627520298188820> solved?
Sun bearOP
Sorry forgot to reply, yeah its solved thank you!
happy to help