@@ -65,6 +65,7 @@ const components = {
6565 return < span > Class</ span > ;
6666 }
6767 } ,
68+ Layout : React . memo ( ( { children } ) => < div > { children } </ div > ) ,
6869} ;
6970
7071const getHOC = ( ) => {
@@ -129,15 +130,23 @@ components.Breadcrumbs.propTypes = {
129130 routes : PropTypes . arrayOf (
130131 PropTypes . oneOfType ( [
131132 PropTypes . shape ( {
132- path : PropTypes . string . isRequired ,
133+ path : PropTypes . string ,
133134 breadcrumb : PropTypes . oneOfType ( [
134135 PropTypes . node ,
135136 PropTypes . func ,
136137 PropTypes . object ,
137138 ] ) ,
138139 } ) ,
139140 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 ,
141150 breadcrumb : PropTypes . oneOfType ( [
142151 PropTypes . node ,
143152 PropTypes . func ,
@@ -174,6 +183,14 @@ components.BreadcrumbExtraPropsTest.propTypes = {
174183 bar : PropTypes . string . isRequired ,
175184} ;
176185
186+ components . Layout . propTypes = {
187+ children : PropTypes . node ,
188+ } ;
189+
190+ components . Layout . defaultProps = {
191+ children : null ,
192+ } ;
193+
177194describe ( 'use-react-router-breadcrumbs' , ( ) => {
178195 describe ( 'Valid routes' , ( ) => {
179196 it ( 'Should render breadcrumb components as expected' , ( ) => {
@@ -314,6 +331,26 @@ describe('use-react-router-breadcrumbs', () => {
314331 expect ( breadcrumbs ) . toBe ( 'Home / One / TwoCustom / ThreeCustom' ) ;
315332 } ) ;
316333
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+
317354 it ( 'Should use the breadcrumb provided by parent if the index route dose not provide one' , ( ) => {
318355 const routes = [
319356 {
0 commit comments