Skip to content

Commit 79875db

Browse files
committed
fix: CBreadcrumbRouter: generate path only if routes are passed
1 parent 5ef9a37 commit 79875db

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/breadcrumb/CBreadcrumbRouter.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,16 @@ const CBreadcrumbRouter = props => {
3939
...attributes
4040
} = props;
4141

42-
const currPath = useLocation().pathname
43-
const paths = getPaths(currPath)
44-
const currRoutes = routes.filter(route => paths.includes(route.path))
42+
let items = null
43+
if (routes) {
44+
const currPath = useLocation().pathname
45+
const paths = getPaths(currPath)
46+
const currRoutes = routes.filter(route => paths.includes(route.path))
47+
items = currRoutes.map(route => {
48+
return CBreadcrumbRouteItem(route, currPath)
49+
})
50+
}
51+
4552

4653
//render
4754

@@ -53,11 +60,7 @@ const CBreadcrumbRouter = props => {
5360
{...attributes}
5461
ref={innerRef}
5562
>
56-
{
57-
currRoutes.map(route => {
58-
return CBreadcrumbRouteItem(route, currPath)
59-
})
60-
}
63+
{items}
6164
</CBreadcrumb>
6265
)
6366
}

0 commit comments

Comments
 (0)