@@ -3,20 +3,39 @@ import { Router, Route, IndexRoute, hashHistory } from 'react-router';
3
3
4
4
import Home from './components/Home' ;
5
5
import ArtistMain from './components/artists/ArtistMain' ;
6
- import ArtistDetail from './components/artists/ArtistDetail' ;
7
- import ArtistCreate from './components/artists/ArtistCreate' ;
8
- import ArtistEdit from './components/artists/ArtistEdit' ;
6
+
7
+ const componentRoutes = {
8
+ component : Home ,
9
+ path : '/' ,
10
+ indexRoute : { component : ArtistMain } ,
11
+ childRoutes : [
12
+ {
13
+ path : 'artists/new' ,
14
+ getComponent ( location , cb ) {
15
+ System . import ( './components/artists/ArtistCreate' )
16
+ . then ( module => cb ( null , module . default ) ) ;
17
+ }
18
+ } ,
19
+ {
20
+ path : 'artists/:id' ,
21
+ getComponent ( location , cb ) {
22
+ System . import ( './components/artists/ArtistDetail' )
23
+ . then ( module => cb ( null , module . default ) ) ;
24
+ }
25
+ } ,
26
+ {
27
+ path : 'artists/:id/edit' ,
28
+ getComponent ( location , cb ) {
29
+ System . import ( './components/artists/ArtistEdit' )
30
+ . then ( module => cb ( null , module . default ) ) ;
31
+ }
32
+ }
33
+ ]
34
+ } ;
9
35
10
36
const Routes = ( ) => {
11
37
return (
12
- < Router history = { hashHistory } >
13
- < Route path = "/" component = { Home } >
14
- < IndexRoute component = { ArtistMain } />
15
- < Route path = "artists/new" component = { ArtistCreate } />
16
- < Route path = "artists/:id" component = { ArtistDetail } />
17
- < Route path = "artists/:id/edit" component = { ArtistEdit } />
18
- </ Route >
19
- </ Router >
38
+ < Router history = { hashHistory } routes = { componentRoutes } />
20
39
) ;
21
40
} ;
22
41
0 commit comments