From 9d4a6848c12178f4dccc46a49dd0f5688e6fb004 Mon Sep 17 00:00:00 2001 From: plandem Date: Fri, 10 Jun 2016 17:22:07 +0300 Subject: [PATCH] fixed case when linkRender must accept raw paths --- components/breadcrumb/Breadcrumb.jsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/components/breadcrumb/Breadcrumb.jsx b/components/breadcrumb/Breadcrumb.jsx index 399a32748a..c59582981a 100644 --- a/components/breadcrumb/Breadcrumb.jsx +++ b/components/breadcrumb/Breadcrumb.jsx @@ -16,7 +16,7 @@ export default class Breadcrumb extends React.Component { static defaultProps = { prefixCls: 'ant-breadcrumb', separator: '/', - linkRender: (href, name) => {name}, + linkRender: (paths, name) => {name}, nameRender: (name) => {name}, nameFormatter: defaultNameFormatter, } @@ -39,6 +39,7 @@ export default class Breadcrumb extends React.Component { const { separator, prefixCls, routes, params, children, linkRender, nameRender, nameFormatter } = this.props; if (routes && routes.length > 0) { const paths = []; + const lastPath = routes.length - 1; crumbs = routes.map((route, i) => { route.path = route.path || ''; let path = route.path.replace(/^\//, ''); @@ -50,17 +51,12 @@ export default class Breadcrumb extends React.Component { } const name = nameFormatter(route, params); - if (!name) { - return null; + if (name) { + const link = (i === lastPath) ? nameRender(name) : linkRender(paths, name); + return {link}; } - let link; - if (i === routes.length - 1) { - link = nameRender(name); - } else { - link = linkRender(`/${paths.join('/')}`, name); - } - return {link}; + return null; }); } else { crumbs = React.Children.map(children, (element, index) => {