Unable to access current route name in component
See original GitHub issueSince this.props.url
is deprecated, we can no longer access the route’s name through the props of the component.
If you append the name of the current route through server.js
, it will stop working during client-side routing.
Inspecting the Router object shows that the ‘name’ of the route is not being appended anywhere, hence the withRouter
solution described in the deprecated page fails too.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Get the current route name into the component - Stack Overflow
I am trying to access the router information from the component because I need to apply a classname depending on the route. Here's...
Read more >How to get current route URL in Angular
Steps to get current route URL in Angular. 1. Import Router,NavigationEnd from angular/router and inject in the constructor. 2.
Read more >Route - Angular
A configuration object that defines a single route. A set of routes are collected in a Routes array to define a Router configuration....
Read more >Routing - Laravel - The PHP Framework For Web Artisans
Middleware; Controllers; Subdomain Routing; Route Prefixes; Route Name Prefixes ... Form Method Spoofing; Accessing The Current Route; Cross-Origin Resource ...
Read more >Navigation Guards | Vue Router
As the name suggests, the navigation guards provided by Vue router are ... these hooks do not get a next function and cannot...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Solution
We extend our
_app.js
file and inject theurl
props to allow it to work as before:Then access the
url
props directly in your pages. Name of the route will be found atthis.props.url.route.name
.Hopefully, this solution will solve a few headaches. Been stuck on this one for the past hour.
Totally! I’m short on time at the moment but review asap. Thanks for contributing!