Maintain history state through redirect #11274
Replies: 2 comments 12 replies
-
I imagine the implementation to this would look something like #11275 (though honestly this is my first time looking at the implementation of this project) |
Beta Was this translation helpful? Give feedback.
-
My initial gut reaction here is that this would be solved by providing You might be able to test this flow today by directly accessing |
Beta Was this translation helpful? Give feedback.
-
Scenario:
Whatever state was passed with the link from /a to /b is lost and replaced with { _isRedirect: true }. Instead of replacing the supplied state with { _isRedirect: true }, I propose adding { _previousState: ... } to the supplied state, so in the scenario above you end with { _isRedirect: true, _previousState: { foo: 'bar' } }
Real world example:
Background
In my app, I am very carefully managing history with appropriate usage of
replace
to ensure the user doesn't go "back" to things like a modal route.For our app if a users navigation is
then we expect the back button to take the user back to the list view, not re-open the modal.
Solution: both opening the modal and closing the modal are done with
replace
to ensure correct historyLocation State Problem
Let's say that when the user went from the list view to the detail view, we passed along some location state. We want this location state preserved as we open/close the modal. The trouble is, if the modal closes via server side redirect, we cannot preserve the location state! It is replaced with
{ _isRedirect: true }
.Have other people dealt with this issue another way? Anyone else have apps where managing the history stack well is really important?
Beta Was this translation helpful? Give feedback.
All reactions