From 28f7dec7e98a9065568b88a226bedcecad3a8250 Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Wed, 13 Apr 2022 22:43:46 -0400 Subject: add lazy loading --- src/App.jsx | 79 +++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 42c3f36..5afcb03 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,10 +1,10 @@ import { useLocation, Routes, Route, Link } from "react-router-dom"; -import { useState } from "react"; +import { useState, lazy, Suspense } from "react"; import useFetch from "./useFetch"; -import Index from "./pages/Index"; import { DateTime } from "luxon"; import "./App.css"; -import Graph from "./pages/Graph"; +const Index = lazy(() => import("./pages/Index")); +const Graph = lazy(() => import("./pages/Graph")); import { useEffect } from "react"; const App = () => { @@ -12,9 +12,10 @@ const App = () => { let routerLocation = useLocation(); useEffect(() => { - !window.goatcounter ?? window.goatcounter.count({ - path: location.pathname + location.search + location.hash, - }); + !window.goatcounter ?? + window.goatcounter.count({ + path: location.pathname + location.search + location.hash, + }); }, [routerLocation]); const response = useFetch(url); @@ -47,48 +48,64 @@ const App = () => { + + + } > + + + } > + + + } > + + + } > - } /> + + + + } + />