@@ -65,6 +65,7 @@ const components = {
65
65
return < span > Class</ span > ;
66
66
}
67
67
} ,
68
+ Layout : React . memo ( ( { children } ) => < div > { children } </ div > ) ,
68
69
} ;
69
70
70
71
const getHOC = ( ) => {
@@ -129,15 +130,23 @@ components.Breadcrumbs.propTypes = {
129
130
routes : PropTypes . arrayOf (
130
131
PropTypes . oneOfType ( [
131
132
PropTypes . shape ( {
132
- path : PropTypes . string . isRequired ,
133
+ path : PropTypes . string ,
133
134
breadcrumb : PropTypes . oneOfType ( [
134
135
PropTypes . node ,
135
136
PropTypes . func ,
136
137
PropTypes . object ,
137
138
] ) ,
138
139
} ) ,
139
140
PropTypes . shape ( {
140
- index : PropTypes . bool . isRequired ,
141
+ index : PropTypes . bool ,
142
+ breadcrumb : PropTypes . oneOfType ( [
143
+ PropTypes . node ,
144
+ PropTypes . func ,
145
+ PropTypes . object ,
146
+ ] ) ,
147
+ } ) ,
148
+ PropTypes . shape ( {
149
+ children : PropTypes . arrayOf ( PropTypes . shape ( ) ) . isRequired ,
141
150
breadcrumb : PropTypes . oneOfType ( [
142
151
PropTypes . node ,
143
152
PropTypes . func ,
@@ -174,6 +183,14 @@ components.BreadcrumbExtraPropsTest.propTypes = {
174
183
bar : PropTypes . string . isRequired ,
175
184
} ;
176
185
186
+ components . Layout . propTypes = {
187
+ children : PropTypes . node ,
188
+ } ;
189
+
190
+ components . Layout . defaultProps = {
191
+ children : null ,
192
+ } ;
193
+
177
194
describe ( 'use-react-router-breadcrumbs' , ( ) => {
178
195
describe ( 'Valid routes' , ( ) => {
179
196
it ( 'Should render breadcrumb components as expected' , ( ) => {
@@ -314,6 +331,26 @@ describe('use-react-router-breadcrumbs', () => {
314
331
expect ( breadcrumbs ) . toBe ( 'Home / One / TwoCustom / ThreeCustom' ) ;
315
332
} ) ;
316
333
334
+ it ( 'Should allow layout routes' , ( ) => {
335
+ const routes = [
336
+ {
337
+ element : < components . Layout /> ,
338
+ children : [
339
+ {
340
+ path : 'about' ,
341
+ breadcrumb : 'About' ,
342
+ } ,
343
+ ] ,
344
+ } ,
345
+ {
346
+ index : true ,
347
+ breadcrumb : 'Home' ,
348
+ } ,
349
+ ] ;
350
+ const { breadcrumbs } = render ( { pathname : '/about' , routes } ) ;
351
+ expect ( breadcrumbs ) . toBe ( 'Home / About' ) ;
352
+ } ) ;
353
+
317
354
it ( 'Should use the breadcrumb provided by parent if the index route dose not provide one' , ( ) => {
318
355
const routes = [
319
356
{
0 commit comments