Lazy load routes

This commit is contained in:
Scald 2023-05-20 06:55:36 +05:30
parent b13541fb7b
commit 96f2e9267f
No known key found for this signature in database
GPG Key ID: 39E71519BFF23499

View File

@ -2,10 +2,11 @@ import React from "react";
import { Routes, Route } from "react-router-dom";
import Header from "@components/Header";
import Loader from "@components/common/Loader";
import Home from "@pages/Home";
import Downloads from "@pages/Downloads";
import ConfigGen from "@pages/ConfigGen";
const Downloads = React.lazy(() => import("@pages/Downloads"));
const ConfigGen = React.lazy(() => import("@pages/ConfigGen"));
import "@css/App.css";
@ -16,10 +17,18 @@ class App extends React.Component {
<Header />
<Routes>
<Route path={"/"} element={<Home />} />
<Route path={"/downloads"} element={<Downloads />} />
<Route path={"/downloads"} element={
<React.Suspense fallback={<Loader />}>
<Downloads />
</React.Suspense>
} />
<Route path={"/wiki"} element={<p>Wiki</p>} />
<Route path={"/features"} element={<p>Features</p>} />
<Route path={"/config"} element={<ConfigGen />} />
<Route path={"/config"} element={
<React.Suspense fallback={<Loader />}>
<ConfigGen />
</React.Suspense>
} />
</Routes>
<div className={"Footer"}>