Skip to content

Commit

Permalink
fix: CBreadcrumbRouter: fix assigning paths to items #118
Browse files Browse the repository at this point in the history
  • Loading branch information
woothu committed Jun 22, 2020
1 parent 293c637 commit 7e2c87b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/breadcrumb/CBreadcrumbRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const getPaths = pathname => {
return paths
}

const CBreadcrumbRouteItem = ({name, path}, currPath) => {
if (path === currPath) {
return <CBreadcrumbItem key={path} active>{name}</CBreadcrumbItem>
const CBreadcrumbRouteItem = ({name, currPath}, fullCurrPath) => {
if (currPath === fullCurrPath) {
return <CBreadcrumbItem key={currPath} active>{name}</CBreadcrumbItem>
} else {
return <CBreadcrumbItem key={path}>
<Link to={path}>
return <CBreadcrumbItem key={currPath}>
<Link to={currPath}>
{name}
</Link>
</CBreadcrumbItem>
Expand All @@ -41,11 +41,12 @@ const CBreadcrumbRouter = props => {
if (routes) {
const currPath = useLocation().pathname
const paths = getPaths(currPath)
const currRoutes = paths.map(path => {
return routes.find(route => matchPath(path, {
const currRoutes = paths.map(currPath => {
const route = routes.find(route => matchPath(currPath, {
path: route.path,
exact: route.exact
}))
return { ...route, currPath }
}).filter(route => route)
items = currRoutes.map(route => {
return CBreadcrumbRouteItem(route, currPath)
Expand Down

0 comments on commit 7e2c87b

Please sign in to comment.