-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathroutes.js
48 lines (45 loc) · 1.03 KB
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import loadable from '@loadable/component';
import { endpoint } from 'config/url';
const Home = loadable(() => import(/* webpackPrefetch: true */ 'pages/home'));
const UserDetail = loadable(() =>
import(/* webpackPrefetch: true */ 'pages/userDetail')
);
const About = loadable(() => import(/* webpackPrefetch: true */ 'pages/about'));
const RedirectAbout = loadable(() =>
import(/* webpackPrefetch: true */ 'pages/redirectAbout')
);
const NotFound = loadable(() =>
import(/* webpackPrefetch: true */ 'pages/notFound')
);
const addExact = (routes) => {
return routes.map((route) =>
route.path !== endpoint.notFound
? {
...route,
exact: true,
}
: route
);
};
export default addExact([
{
path: endpoint.home,
component: Home,
},
{
path: endpoint.userDetail,
component: UserDetail,
},
{
path: endpoint.about,
component: About,
},
{
path: endpoint.redirectAbout,
component: RedirectAbout,
},
{
path: endpoint.notFound,
component: NotFound,
},
]);