yN.
yN.

Reputation: 2257

React Router: How to link back to scroll position of previous page

Imaging a page (vertical scrollable) full of thumbnails of images. When clicking on a thumbnail the image opens in fullscreen. It has a <Link /> which leads back to the thumbnail page. Currently this leads to the top of the thumbnail page.

How can I instead link to the last scroll position?

Upvotes: 1

Views: 969

Answers (1)

ChrisR
ChrisR

Reputation: 4008

As you know which thumbnail you just displayed, you could set an id on them, and when you click back to the thumbnail page, you can make the page scroll to the position of the last displayed id/image.

Upvotes: 2

Related Questions