[react] Return to the previous list after moving to the detail page
In the item list, if you go back after moving to the detail page, the previous list should be maintained.
* The list of items must be intact.
* The scroll must be at the previous entry point.
* It should load quickly.
How to implement the above function? Unless you are a developer, what you should be doing is not supported.
If it’s a server-side rendered page, it can be even more tricky. Currently, delog.io uses nextjs to run the server-side page as standard.
The way I implemented it uses the history object.
The history object remains stateful until refreshed. Suitable for use when page movement is required.
1. Load the list.
. * Save the list to the history.
2. When selecting an item, the scroll position is saved in history. (to get the position back when returning to the list)
3. If you press the back button on the detail page,
. * If you came from a detailed page, cached data is distributed.
. * Returns the scroll to the previously saved position.
The same method as above was applied to server-side rendering.