File tree Expand file tree Collapse file tree 1 file changed +11
-14
lines changed Expand file tree Collapse file tree 1 file changed +11
-14
lines changed Original file line number Diff line number Diff line change 1- import React from 'react' ;
1+ import { createElement } from 'react' ;
22import { matchPath , withRouter } from 'react-router' ;
33
44const DEFAULT_MATCH_OPTIONS = { exact : true } ;
@@ -23,7 +23,7 @@ export const getBreadcrumbs = ({ routes, pathname }) => {
2323 // combine the last route section with the current
2424 // ex `pathname = /1/2/3 results in match checks for
2525 // `/1`, `/1/2`, `/1/2/3`
26- const pathSection = current === '' ? '/' : `${ previous } /${ current } ` ;
26+ const pathSection = ! current ? '/' : `${ previous } /${ current } ` ;
2727
2828 let breadcrumbMatch ;
2929
@@ -53,19 +53,16 @@ export const getBreadcrumbs = ({ routes, pathname }) => {
5353 }
5454
5555 return pathSection === '/' ? '' : pathSection ;
56- } , '' ) ;
56+ } , null ) ;
5757
5858 return matches ;
5959} ;
6060
61- export const withBreadcrumbs = routes => Component => withRouter ( props => (
62- < Component
63- { ...props }
64- breadcrumbs = {
65- getBreadcrumbs ( {
66- pathname : props . location . pathname ,
67- routes,
68- } )
69- }
70- />
71- ) ) ;
61+ export const withBreadcrumbs = routes => Component => withRouter ( props =>
62+ createElement ( Component , {
63+ ...props ,
64+ breadcrumbs : getBreadcrumbs ( {
65+ pathname : props . location . pathname ,
66+ routes,
67+ } ) ,
68+ } ) ) ;
You can’t perform that action at this time.
0 commit comments