Dynamic route doesn't work in 4.0
See original GitHub issueroutes.js
const routes = [
{ path: "/", exact: true, name: "Home" },
{ path: "/product/list", name: "ProductList", component: ProductList },
{ path: "/product/detail/:id", name: "ProductDetail", component: ProductDetail }
];
when I enter /product/detail/2, It throws Uncaught TypeError: Cannot read property ‘name’ of undefined.
AppGreadcrumb.js
const getRouteName = (pathname, routes) => {
const currentRoute = routes.find((route) => route.path === pathname);
return currentRoute.name;
};
I guess that ‘/product/detail/:id’ is not same as '/product/detail/2, so currentRoute return undefined and getRouteName function throw error.
Thanks.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Dynamic route not working in build version of my react app
The following route is dynamic and doesn't work. However, my guess is that it is not due to ":processFlowItemId" but instead due to ......
Read more >Basics → Routing - Vapor Docs
To understand how routing works in Vapor, you should first understand a few basics ... based on the HTTP method and path, let's...
Read more >Troubleshooting | Cloud Router
Use the following guide to troubleshoot common issues with Cloud Router: Configuration issues related to configuring and establishing BGP sessions.
Read more >Routes' Matching Syntax - Vue Router
Routes' Matching Syntax #. Watch a free video lesson on Vue School. Most applications will use static routes like /about and dynamic routes...
Read more >Specifying a Route's Model - Ember Guides
Sometimes you need to fetch a model, but your route doesn't have the parameters, because it's a child route and the route directly...
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
I was able to fix this by changing the
getRouteName
to:You will also need to add the following import:
Hi… how to make this in react 18. This code is not working on it. Browser console says ’ No routes matched location “/admin/sometexthere” ’