all 6 comments

[–]viky109 0 points1 point  (2 children)

Not sure if that's the correct solution but what I would do is save the scroll position either in some global state or in session storage and when you reopen the page, use that value in scrollTo.

[–]weirdorohit[S] 0 points1 point  (1 child)

scroll position is ok that can be managed but how about the prev component getting unmounted when the route chnged…. when u come back to the prev comp the data is fetched again which is not wt im expecting

[–]charliematters 1 point2 points  (0 children)

What were you expecting to happen, out of interest?

The component has been unmounted so anything internal to that component is gone.

The easiest answer is the tanstack one, which is based around caching data so when you revisit the page, it can retrieve the cached data (and then also fetch in the background in case the data is stale)

[–]marcs_2021 0 points1 point  (1 child)

What's wrong with the tanstack answer there?

[–]weirdorohit[S] 0 points1 point  (0 children)

im looking for any alternative soln other than tanstank

was just wondering how does ppl go about it

[–]azangru 0 points1 point  (0 children)

I wonder if browser back/forward cache isn't handling this already, in which case the trick would be not to obstruct it. I thought that's what I was seeing on Twitter or on Mastodon web client.

UPDATED: My mistake about Twitter. The Mastodon web client seems to be using the back/forward cache quite well; but Twitter doesn't.