0

I'm using React with react-router v4 for routing in a SPA app.

From within a list page, when user taps on an item, we navigate to detail url which renders detail component.

From here, if I click back, route transitions to list page but list page itself is reloaded. So its scroll position, selection of an item (which opened the details page) is lost.

I have been struggling to think about how to approach this problem. One way I was thinking is to build all pages to open as model on top of another so base page context is always there and when user navigates back, I can start to close the modals revealing previous page in its exact state.

Not sure if that is a right approach.

laser
  • 1,388
  • 13
  • 14
singularity
  • 1,057
  • 2
  • 10
  • 20

1 Answers1

1

You could store the current scroll position locally, then scroll back to it when your list page component is mounted.

These are jQuery answers, but the principle is the same:

RogerH
  • 21
  • 6