forked from emre/www_projectmycelium_com
		
	perf: implement lazy loading for route components
- Added React.lazy() for all page components to enable code splitting - Wrapped Routes with Suspense component and loading fallback state - Converted static imports to dynamic imports to reduce initial bundle size - Added semicolons for consistent code style
This commit is contained in:
		
							
								
								
									
										24
									
								
								src/App.tsx
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								src/App.tsx
									
									
									
									
									
								
							@@ -1,17 +1,20 @@
 | 
			
		||||
import { BrowserRouter, Routes, Route } from 'react-router-dom'
 | 
			
		||||
import { Layout } from './components/Layout'
 | 
			
		||||
import HomePage from './pages/home/HomePage'
 | 
			
		||||
import CloudPage from './pages/cloud/CloudPage'
 | 
			
		||||
import NetworkPage from './pages/network/NetworkPage'
 | 
			
		||||
import AgentsPage from './pages/agents/AgentsPage'
 | 
			
		||||
import DownloadPage from './pages/download/DownloadPage'
 | 
			
		||||
import ComputePage from './pages/compute/ComputePage'
 | 
			
		||||
import StoragePage from './pages/storage/StoragePage'
 | 
			
		||||
import GpuPage from './pages/gpu/GpuPage'
 | 
			
		||||
import { BrowserRouter, Routes, Route } from 'react-router-dom';
 | 
			
		||||
import { Layout } from './components/Layout';
 | 
			
		||||
import { lazy, Suspense } from 'react';
 | 
			
		||||
 | 
			
		||||
const HomePage = lazy(() => import('./pages/home/HomePage'));
 | 
			
		||||
const CloudPage = lazy(() => import('./pages/cloud/CloudPage'));
 | 
			
		||||
const NetworkPage = lazy(() => import('./pages/network/NetworkPage'));
 | 
			
		||||
const AgentsPage = lazy(() => import('./pages/agents/AgentsPage'));
 | 
			
		||||
const DownloadPage = lazy(() => import('./pages/download/DownloadPage'));
 | 
			
		||||
const ComputePage = lazy(() => import('./pages/compute/ComputePage'));
 | 
			
		||||
const StoragePage = lazy(() => import('./pages/storage/StoragePage'));
 | 
			
		||||
const GpuPage = lazy(() => import('./pages/gpu/GpuPage'));
 | 
			
		||||
 | 
			
		||||
function App() {
 | 
			
		||||
  return (
 | 
			
		||||
    <BrowserRouter>
 | 
			
		||||
      <Suspense fallback={<div>Loading...</div>}>
 | 
			
		||||
        <Routes>
 | 
			
		||||
          <Route path="/" element={<Layout />}>
 | 
			
		||||
            <Route index element={<HomePage />} />
 | 
			
		||||
@@ -24,6 +27,7 @@ function App() {
 | 
			
		||||
            <Route path="gpu" element={<GpuPage />} />
 | 
			
		||||
          </Route>
 | 
			
		||||
        </Routes>
 | 
			
		||||
      </Suspense>
 | 
			
		||||
    </BrowserRouter>
 | 
			
		||||
  )
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user