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 1
1
export { default as ErrorPage } from './ErrorPage' ;
2
2
export { default as Footer } from './Footer' ;
3
3
export { default as Header } from './Header' ;
4
+ export { default as RouteWithSubRoutes } from './RouteWithSubRoutes' ;
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import { Switch , Route } from 'react-router-dom' ;
2
+ import { Switch } from 'react-router-dom' ;
3
+ import { RouteWithSubRoutes } from 'components/common' ;
3
4
import { Container } from 'semantic-ui-react' ;
4
5
import { Header , Footer } from 'components/common' ;
5
6
import routes from 'routes' ;
@@ -8,7 +9,9 @@ const App = () => (
8
9
< Container fluid = { false } >
9
10
< Header />
10
11
< Switch >
11
- { routes . map ( route => < Route key = { route . path } { ...route } /> ) }
12
+ { routes . map ( route => (
13
+ < RouteWithSubRoutes key = { route . path } { ...route } />
14
+ ) ) }
12
15
</ Switch >
13
16
< Footer />
14
17
</ Container >
You can’t perform that action at this time.
0 commit comments