-
Notifications
You must be signed in to change notification settings - Fork 597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Code to listen for 'navigation' change does not output written behavior #627
Comments
Here's the link to the routing documentation: https://github.com/choojs/website/blame/49f3b8d4aabbadaf67c13854fb3ce680a57374dd/content/docs/routing/index.md#L340 I don't think that this ever worked in v6... maybe in earlier versions. |
if we're considering changing the api here (to, from) would be cool. |
yeah, knowing the previous route would be really useful! |
We won't have access to the previous state anymore with the current setup. ... I'm also not sure how we should differentiate the state in before and after hooks. |
re: knowing the previous route: How about adding a previousRoute property to the state? Choo.prototype._matchRoute = function (locationOverride) {
var location, queryString
if (locationOverride) {
location = locationOverride.replace(/\?.+$/, '')
queryString = locationOverride
} else {
location = this._createLocation()
queryString = window.location.search
}
var matched = this.router.match(location)
this.state.href = location
this.state.query = nanoquery(queryString)
+ this.state.previousRoute = this.state.route
this.state.route = matched.route
this.state.params = matched.params
this.state._handler = matched.cb
return this.state I'm looking at animating route transitions and having access to previous route (somehow, doesn't have to be this way) would be super useful. As for the docs reflecting actual behavior I made a small pr here: choojs/website#61 |
Expected behavior
In the Choo docs on Routing, in the section "Listening for Route Changes" implementing:
Should return a console message "Navigated to [insert route here]
Actual behavior
This code snippet instead returns a console message "Navigated to undefined"
Steps to reproduce behavior
The text was updated successfully, but these errors were encountered: