|
@@ -1,20 +1,25 @@
|
|
|
-import React from "react";
|
|
|
+import React, { lazy, Suspense } from "react";
|
|
|
import { Switch, Route } from "react-router-dom";
|
|
|
-import App from "./container/App";
|
|
|
-import FetchPage from "./container/fetchPage";
|
|
|
+// import App from "./container/App";
|
|
|
+// import FetchPage from "./container/fetchPage";
|
|
|
import Auth from "./container/Auth";
|
|
|
|
|
|
import Header from "./components/header";
|
|
|
|
|
|
import PrivateRoute from "./privateRouter";
|
|
|
|
|
|
+const app = lazy(() => import("./container/Auth"));
|
|
|
+const FetchPage = lazy(() => import("./container/fetchPage"));
|
|
|
+
|
|
|
export default () => (
|
|
|
<div className="container">
|
|
|
- <Header />
|
|
|
- <Switch>
|
|
|
- <PrivateRoute path="/" exact component={App} />
|
|
|
- <Route path="/auth" render={props => <Auth name="Tony" {...props} />} />
|
|
|
- <Route exact path="/fetch" component={FetchPage} />
|
|
|
- </Switch>
|
|
|
+ <Suspense fallback={<div>Loading...</div>}>
|
|
|
+ <Header />
|
|
|
+ <Switch>
|
|
|
+ <PrivateRoute path="/" exact component={app} />
|
|
|
+ <Route path="/auth" render={props => <Auth name="Tony" {...props} />} />
|
|
|
+ <Route exact path="/fetch" component={FetchPage} />
|
|
|
+ </Switch>
|
|
|
+ </Suspense>
|
|
|
</div>
|
|
|
);
|