Skip to content

Commit

Permalink
Merge pull request #26 from coreui/dev-vnext
Browse files Browse the repository at this point in the history
refactor(Breadcrumb): fix for dynamic url like /path/:id
  • Loading branch information
xidedix authored Jun 20, 2018
2 parents 5c57508 + 969bd9c commit 7a23c11
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coreui/react",
"version": "2.0.3",
"version": "2.0.4",
"description": "CoreUI React Bootstrap 4 components",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -38,7 +38,7 @@
"@coreui/icons": "0.2.0",
"classnames": "^2.2.6",
"core-js": "^2.5.7",
"prop-types": "^15.6.1",
"prop-types": "^15.6.2",
"react-perfect-scrollbar": "^1.1.1",
"react-router-dom": "^4.3.1",
"reactstrap": "^6.1.0"
Expand Down
9 changes: 3 additions & 6 deletions src/Breadcrumb.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Route, Link } from 'react-router-dom';
import { Route, Link, matchPath } from 'react-router-dom';
import { Breadcrumb, BreadcrumbItem } from 'reactstrap';
import PropTypes from 'prop-types';
import classNames from 'classnames';
Expand All @@ -20,11 +20,8 @@ const getPaths = (pathname) => {
};

const findRouteName = (url) => {
const aroute = routes.find(route => route.path === url);
if (aroute && aroute.name) {
return aroute.name;
}
return null;
const aroute = routes.find(route => matchPath(url, {path: route.path, exact: route.exact}));
return (aroute && aroute.name) ? aroute.name : null
};

const BreadcrumbsItem = ({ match }) => {
Expand Down

0 comments on commit 7a23c11

Please sign in to comment.