#scroll restoration
1 messages ยท Page 1 of 1 (latest)
Instead of adding this to _app.js, I would add this to the catalogue page
since you only want it for that page
What Im doing inside the page I want the scroll restoration is just this
const updateScroll = useRouterScroll()?.updateScroll;
useEffect(() => {
if (updateScroll) {
updateScroll();
}
}, [updateScroll]);
and works fine for me ^^ (edit: I find this easier that shouldUpdateScroll )
yeah but then I have to apply that to each page (except catalogue)
wouldn't be a bit redundant like that?
or it's ok ?
Didnt you say you only want it for one page? If its multiple pages then yea its better to use shouldUpdateScroll
yes
with this i mean
Hard to tell without knowing more about the project. Is there any case where you might want to rerun updateScroll maybe? ๐ค
you can also look at the SessionStorage on your dev tools to see the values of the scroll positions
localStorage worked easier ๐
I think I should just use that
Because I realize in docs it says I have to actually use this library on top of that to provide correct constructed new behavior to make it work with shouldUpdateScrollhttps://github.com/taion/scroll-behavior#custom-scroll-behavior