File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -10,18 +10,20 @@ const AppBreadcrumb = () => {
1010
1111 const getRouteName = ( pathname , routes ) => {
1212 const currentRoute = routes . find ( ( route ) => route . path === pathname )
13- return currentRoute . name
13+ return currentRoute ? currentRoute . name : false
1414 }
1515
1616 const getBreadcrumbs = ( location ) => {
1717 const breadcrumbs = [ ]
1818 location . split ( '/' ) . reduce ( ( prev , curr , index , array ) => {
1919 const currentPathname = `${ prev } /${ curr } `
20- breadcrumbs . push ( {
21- pathname : currentPathname ,
22- name : getRouteName ( currentPathname , routes ) ,
23- active : index + 1 === array . length ? true : false ,
24- } )
20+ const routeName = getRouteName ( currentPathname , routes )
21+ routeName &&
22+ breadcrumbs . push ( {
23+ pathname : currentPathname ,
24+ name : routeName ,
25+ active : index + 1 === array . length ? true : false ,
26+ } )
2527 return currentPathname
2628 } )
2729 return breadcrumbs
You can’t perform that action at this time.
0 commit comments