Skip to content

Commit b86d4f6

Browse files
committed
fix(AppBreadcrumb): add support for dynamic paths
1 parent c416d0b commit b86d4f6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/components/AppBreadcrumb.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ const AppBreadcrumb = () => {
1010

1111
const getRouteName = (pathname, routes) => {
1212
const currentRoute = routes.find((route) => route.path === pathname)
13-
return currentRoute.name
13+
return currentRoute ? currentRoute.name : false
1414
}
1515

1616
const getBreadcrumbs = (location) => {
1717
const breadcrumbs = []
1818
location.split('/').reduce((prev, curr, index, array) => {
1919
const currentPathname = `${prev}/${curr}`
20-
breadcrumbs.push({
21-
pathname: currentPathname,
22-
name: getRouteName(currentPathname, routes),
23-
active: index + 1 === array.length ? true : false,
24-
})
20+
const routeName = getRouteName(currentPathname, routes)
21+
routeName &&
22+
breadcrumbs.push({
23+
pathname: currentPathname,
24+
name: routeName,
25+
active: index + 1 === array.length ? true : false,
26+
})
2527
return currentPathname
2628
})
2729
return breadcrumbs

0 commit comments

Comments
 (0)