memos
memos copied to clipboard
Add scroll restoration when navigates back
This PR fixes #3277 issue.
I refactor the Home component to make the react-router-dom ScrollRestoration work. There are some useless re-rendering that makes the ScrollRestoration not work.
Here's the demo https://www.veed.io/view/d774a53a-fcd9-4c9f-afe2-d145e204dcc2?panel=share
Sorry, I've just noticed there's a bug. When we navigate back from memo detail and the Home page already has more than 1 page of memos in the store (I mean the zustand store), the next page token is reset.
We need to move it out to the zustand store so it doesn't reset when navigating back.
I'll take a look at this when I have spare time.
I encountered many problems because we reused the same store on multiple pages (the homepage, the explore page, and others).
I think we can do a workaround. By using full page reload when navigating pages between home, explore, timeline, and other pages that show memo lists and use the same store, we can prevent the bug and enable the scroll restoration feature.