You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 21, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 21, 2026. It is now read-only.
Should appHistory.navigate()'s state option work for cross-document navigations? #98
I strongly suspect the answer is "no": giving a new way to pass state across documents seems a bit fraught. At the very least it'd have to be origin-constrained.
I wanted to file this issue to track this as a somewhat-open question, and get any community input. But the spec in #96 currently ignores state for cross-document navigations.
I'm starting to wonder whether you would ever want to use the navigate() API for a cross-origin navigation.
Should we just throw an error if you try to do that? And create a separate api for cross-origin navigation that doesn't take anything but a url and navigateInfo?
I think it could potentially be reasonable to pass state across documents. If you can embed something in the URL (serialize to string) you could embed it in the state object, and vice-versa.
I'm starting to wonder whether you would ever want to use the navigate() API for a cross-origin navigation.
Should we just throw an error if you try to do that? And create a separate api for cross-origin navigation that doesn't take anything but a url and navigateInfo?
Well, it'd be nice as a new "better location.assign()". I can imagine situations where you don't know whether the URL you're getting is cross-origin or same-origin, and you just want to use navigateInfo; having to parse the URL and then switch between two methods sounds less good.
I tried to write a test today that used appHistory.reload({ state: newState }), and I did not preventDefault() on the navigate event. It caught me by surprise that the state was ignored.
But, it's probably still good to be consistent between reload() and navigate() in this sense?
Activity
tbondwilkinson commentedon Apr 16, 2021
I'm starting to wonder whether you would ever want to use the navigate() API for a cross-origin navigation.
Should we just throw an error if you try to do that? And create a separate api for cross-origin navigation that doesn't take anything but a url and navigateInfo?
I think it could potentially be reasonable to pass state across documents. If you can embed something in the URL (serialize to string) you could embed it in the state object, and vice-versa.
domenic commentedon Apr 19, 2021
Well, it'd be nice as a new "better
location.assign()". I can imagine situations where you don't know whether the URL you're getting is cross-origin or same-origin, and you just want to usenavigateInfo; having to parse the URL and then switch between two methods sounds less good.domenic commentedon May 27, 2021
Yeah, let's leave this as no...
domenic commentedon Aug 6, 2021
I tried to write a test today that used
appHistory.reload({ state: newState }), and I did notpreventDefault()on the navigate event. It caught me by surprise that the state was ignored.But, it's probably still good to be consistent between
reload()andnavigate()in this sense?