-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[changed] handlers receive route name #157
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
Conversation
I kind of want to just pass |
I think I agree, it should go to the transition hooks too. |
I ran into this within 30 minutes of setting up an extremely simple master/detail app. directly with the I want to know the current route to display the name in the header but there isn't any easy way to introspect it (this coincides with the identified use case of "managing document title"). Considering that the |
@mjackson seems good? |
Yeah, I'm 👍. We should probably talk a little more about what things you'd like to pass through to transition hooks as well, but in a separate issue. |
[changed] handlers receive route name
for google searchers, this can now be accomplished like so:
|
//insert sardonic comment here...
var routeName = this.getRoutes()[this.getRoutes().length-1].name; This works, but don't you think it should just be router.name? |
In React Router 1.0.0, inside of a route component you can do this without importing anything:
|
@9o This won't work well for urls with parameters, e.g. |
There are a lot of requests to introspect in handlers on the route name. We transfer other "static" props to the handler, why not
name
?Some requests: #150, #119.
Use cases:
But really, best argument for passing it down to the handler is that we pass other props down and there is no harm in the handler knowing the name of the route its handling.
If we don't pass it in, then people can/will just do this instead: