8000 fix: CBreadcrumbRouter: fix assigning paths to items #118 · AdnanBoota/coreui-react@7e2c87b · GitHub
[go: up one dir, main page]

Skip to content

Commit 7e2c87b

Browse files
committed
fix: CBreadcrumbRouter: fix assigning paths to items coreui#118
1 parent 293c637 commit 7e2c87b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/breadcrumb/CBreadcrumbRouter.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ const getPaths = pathname => {
1616
return paths
1717
}
1818

19-
const CBreadcrumbRouteItem = ({name, path}, currPath) => {
20-
if (path === currPath) {
21-
return <CBreadcrumbItem key={path} active>{name}</CBreadcrumbItem>
19+
const CBreadcrumbRouteItem = ({name, currPath}, fullCurrPath) => {
20+
if (currPath === fullCurrPath) {
21+
return <CBreadcrumbItem key={currPath} active>{name}</CBreadcrumbItem>
2222
} else {
23-
return <CBreadcrumbItem key={path}>
24-
<Link to={path}>
23+
return <CBreadcrumbItem key={currPath}>
24+
<Link to={currPath}>
2525
{name}
2626
</Link>
2727
</CBreadcrumbItem>
@@ -41,11 +41,12 @@ const CBreadcrumbRouter = props => {
4141
if (routes) {
4242
const currPath = useLocation().pathname
4343
const paths = getPaths(currPath)
44-
const currRoutes = paths.map(path => {
45-
return routes.find(route => matchPath(path, {
44+
const currRoutes = paths.map(currPath => {
45+
const route = routes.find(route => matchPath(currPath, {
4646
path: route.path,
4747
exact: route.exact
4848
}))
49+
return { ...route, currPath }
4950
}).filter(route => route)
5051
items = currRoutes.map(route => {
5152
return CBreadcrumbRouteItem(route, currPath)

0 commit comments

Comments
 (0)
0