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
I'm working on a project where it would be really useful to know if the user navigated forward (push state) or backwards (pop state).
I had a look at the source code and it looks like the popstate event listener could call routeTo with an additional parameter that indicates the route is caused by the history popping a state.
I think this would be a nice addition. The 'back' concept gets a bit murky when the user uses forward history navigation, since that also fires the popstate event. The new App History API provides an explicit indicator for this, but it's only available in Chrome currently.
I'm working on a project where it would be really useful to know if the user navigated forward (push state) or backwards (pop state).
I had a look at the source code and it looks like the
popstate
event listener could callrouteTo
with an additional parameter that indicates the route is caused by the history popping a state.Something like:
The parameter could then be stored in
state
and passed as a prop to the component and the onChangeRoute callback.I did a little testing and got it working quite easily (see diffs here). I could make it a PR if this is something worth adding to preact-router.
Thanks!
The text was updated successfully, but these errors were encountered: