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 = () => {
10
10
11
11
const getRouteName = ( pathname , routes ) => {
12
12
const currentRoute = routes . find ( ( route ) => route . path === pathname )
13
- return currentRoute . name
13
+ return currentRoute ? currentRoute . name : false
14
14
}
15
15
16
16
const getBreadcrumbs = ( location ) => {
17
17
const breadcrumbs = [ ]
18
18
location . split ( '/' ) . reduce ( ( prev , curr , index , array ) => {
19
19
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
+ } )
25
27
return currentPathname
26
28
} )
27
29
return breadcrumbs
You can’t perform that action at this time.
0 commit comments