T
TanStack3y ago
wise-white

Scroll Restoration?

How is scroll restoration handled? Currently doing it the ole fashion ugly way:
useEffect(() => {
window.scrollTo(0,0)
}, [window.location.pathname])
useEffect(() => {
window.scrollTo(0,0)
}, [window.location.pathname])
4 Replies
wise-white
wise-whiteOP3y ago
Or like a route change?
xenial-black
xenial-black3y ago
typically scroll restoration is more involved than a scrollTo reset, you keep the scroll position from before navigation to a new route and then return to that position if you go back to that route (emulating browser behaviors)
wise-white
wise-whiteOP3y ago
Yeah that’s my preference. But is there any way I can do that with this library?
xenial-black
xenial-black3y ago
theoretically yes but i don't think anyone has written that yet

Did you find this page helpful?