Open pauloevpr opened 1 year ago
I think the issue is the router needs to support transitions, so it doesn't want to update the browser history until after that completes.
In the destination component, do you get a better result using the router's useLocation()
state instead?
Alternatively, but perhaps not ideal, if you use a plain <a>
tag then the url is updated first and the router only finds out about that afterward.
I agree with this. We should have state present as part of the transition exposed through our own primitives. I don't think there is a good decision either way if we can't tap into our Transitions.
Moving this to router repo as that is where it belongs.
When passing history state to
<A>
like this:the state is not available in the destination page/component. Calling
history.state
in the destination component's setup function or even withinonMount
will always returnundefined
. This seems to happen because@solidjs/router
callshistory.pushState
after everything else in the navigation workflow happens.I would imagine that updating the history would ideally be the very first step in the navigation workflow. This is to be consistent with the back/forward navigation triggered by
popstate
where the history is the very first thing to be updated. If the history is always updated first, thenhistory.state
will consistently be available to the page.