|
1 | 1 | import React from "react"; |
2 | 2 | import { Route, Switch } from "react-router-dom"; |
| 3 | +import asyncComponent from "./components/AsyncComponent"; |
3 | 4 | import AppliedRoute from "./components/AppliedRoute"; |
4 | 5 | import AuthenticatedRoute from "./components/AuthenticatedRoute"; |
5 | 6 | import UnauthenticatedRoute from "./components/UnauthenticatedRoute"; |
6 | 7 |
|
7 | | -import Home from "./containers/Home"; |
8 | | -import Login from "./containers/Login"; |
9 | | -import Notes from "./containers/Notes"; |
10 | | -import Signup from "./containers/Signup"; |
11 | | -import NewNote from "./containers/NewNote"; |
12 | | -import NotFound from "./containers/NotFound"; |
| 8 | +const AsyncHome = asyncComponent(() => import("./containers/Home")); |
| 9 | +const AsyncLogin = asyncComponent(() => import("./containers/Login")); |
| 10 | +const AsyncNotes = asyncComponent(() => import("./containers/Notes")); |
| 11 | +const AsyncSignup = asyncComponent(() => import("./containers/Signup")); |
| 12 | +const AsyncNewNote = asyncComponent(() => import("./containers/NewNote")); |
| 13 | +const AsyncNotFound = asyncComponent(() => import("./containers/NotFound")); |
13 | 14 |
|
14 | 15 | export default ({ childProps }) => |
15 | 16 | <Switch> |
16 | | - <AppliedRoute path="/" exact component={Home} props={childProps} /> |
17 | | - |
18 | | - <UnauthenticatedRoute path="/login" exact component={Login} props={childProps} /> |
19 | | - <UnauthenticatedRoute path="/signup" exact component={Signup} props={childProps} /> |
20 | | - <AuthenticatedRoute path="/notes/:id" exact component={Notes} props={childProps} /> |
21 | | - <AuthenticatedRoute path="/notes/new" exact component={NewNote} props={childProps} /> |
| 17 | + <AppliedRoute path="/" exact component={AsyncHome} props={childProps} /> |
| 18 | + <UnauthenticatedRoute path="/login" exact component={AsyncLogin} props={childProps} /> |
| 19 | + <UnauthenticatedRoute path="/signup" exact component={AsyncSignup} props={childProps} /> |
| 20 | + <AuthenticatedRoute path="/notes/new" exact component={AsyncNewNote} props={childProps} /> |
| 21 | + <AuthenticatedRoute path="/notes/:id" exact component={AsyncNotes} props={childProps} /> |
22 | 22 | { /* Finally, catch all unmatched routes */ } |
23 | | - <Route component={NotFound} /> |
| 23 | + <Route component={AsyncNotFound} /> |
24 | 24 | </Switch>; |
0 commit comments