aboutsummaryrefslogtreecommitdiffstats
path: root/src/App.tsx
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2020-10-12 15:04:06 +0100
committerGravatar GitHub <[email protected]>2020-10-12 15:04:06 +0100
commit0abf07647a7f56ecd4b16c3bd0b6aef9cf8052a8 (patch)
tree324220fcdf616152d8743e59b2ac6dcb6c6db816 /src/App.tsx
parentMerge pull request #22 from python-discord/sentry/add-sentry-prefix (diff)
parentRemove unused dependencies (diff)
Merge pull request #23 from python-discord/build/new-process
Introduce new build system: SWC
Diffstat (limited to 'src/App.tsx')
-rw-r--r--src/App.tsx17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/App.tsx b/src/App.tsx
index 19ba6a6..56aff08 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,5 +1,6 @@
/** @jsx jsx */
/** @global location */
+import React, { Suspense } from "react";
import { jsx, Global } from "@emotion/core";
import {
@@ -8,14 +9,16 @@ import {
Switch
} from "react-router-dom";
-import { CSSTransition, TransitionGroup } from "react-transition-group";
+import { HashLoader } from "react-spinners";
-import LandingPage from "./pages/LandingPage";
-import FormPage from "./pages/FormPage";
-import CallbackPage from "./pages/CallbackPage";
+import { CSSTransition, TransitionGroup } from "react-transition-group";
import globalStyles from "./globalStyles";
+const LandingPage = React.lazy(() => import("./pages/LandingPage"));
+const FormPage = React.lazy(() => import("./pages/FormPage"));
+const CallbackPage = React.lazy(() => import("./pages/CallbackPage"));
+
const routes = [
{ path: "/", Component: LandingPage },
{ path: "/form/:id", Component: FormPage},
@@ -36,7 +39,11 @@ function App() {
>
<Switch location={location}>
{routes.map(({path, Component}) => (
- <Route key={path} exact path={path} component={Component}/>
+ <Route exact key={path} path={path}>
+ <Suspense fallback={<HashLoader color="white"/>}>
+ <Component/>
+ </Suspense>
+ </Route>
))}
</Switch>
</CSSTransition>