Skip to content

Commit

Permalink
Add Suspense component
Browse files Browse the repository at this point in the history
  • Loading branch information
KnotzerIO committed Mar 31, 2024
1 parent 3bf3ef8 commit 26f2c0c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { createContext } from "react";
import { Suspense, createContext } from "react";
import { Route, Routes } from "react-router-dom";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import "./styles/App.css";
import Map from "./pages/Map";
import { AdminContextType } from "./utils/types";
import Loading from "./pages/Loading";

export const AdminContext = createContext<AdminContextType | null>(null);
function App() {
return (
<div className="flex flex-col relative w-full max-h-[100dvh]">
<Routes>
<Route path="/:postion?" element={<Map />} />
</Routes>
<ToastContainer position="bottom-left" closeOnClick autoClose={2500} />
</div>
<Suspense fallback={<Loading />}>
<div className="flex flex-col relative w-full max-h-[100dvh]">
<Routes>
<Route path="/:postion?" element={<Map />} />
</Routes>
<ToastContainer position="bottom-left" closeOnClick autoClose={2500} />
</div>
</Suspense>
);
}

Expand Down
10 changes: 10 additions & 0 deletions src/pages/Loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import logo from "@/assets/img/pathpal-logo.svg";
function Loading() {
return (
<div className="flex items-center justify-center h-screen">
<img src={logo} alt="PathPal Logo" className="w-32 h-32 animate-spin" />
</div>
);
}

export default Loading;

0 comments on commit 26f2c0c

Please sign in to comment.