File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { Route } from 'react-router' ;
3+
4+ const RouteWithSubRoutes = props => {
5+ const {
6+ path,
7+ computedMatch,
8+ component : Component ,
9+ routes,
10+ restProps
11+ } = props ;
12+
13+ return (
14+ < Route
15+ path = { path }
16+ render = { props => {
17+ // pass the sub-routes down to keep nesting
18+ return (
19+ < Component
20+ { ...props }
21+ { ...restProps }
22+ match = { computedMatch }
23+ routes = { routes }
24+ />
25+ ) ;
26+ } }
27+ />
28+ ) ;
29+ } ;
30+
31+ export default RouteWithSubRoutes ;
Original file line number Diff line number Diff line change 11export { default as ErrorPage } from './ErrorPage' ;
22export { default as Footer } from './Footer' ;
33export { default as Header } from './Header' ;
4+ export { default as RouteWithSubRoutes } from './RouteWithSubRoutes' ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
2- import { Switch , Route } from 'react-router-dom' ;
2+ import { Switch } from 'react-router-dom' ;
3+ import { RouteWithSubRoutes } from 'components/common' ;
34import { Container } from 'semantic-ui-react' ;
45import { Header , Footer } from 'components/common' ;
56import routes from 'routes' ;
@@ -8,7 +9,9 @@ const App = () => (
89 < Container fluid = { false } >
910 < Header />
1011 < Switch >
11- { routes . map ( route => < Route key = { route . path } { ...route } /> ) }
12+ { routes . map ( route => (
13+ < RouteWithSubRoutes key = { route . path } { ...route } />
14+ ) ) }
1215 </ Switch >
1316 < Footer />
1417 </ Container >
You can’t perform that action at this time.
0 commit comments