-
-
Notifications
You must be signed in to change notification settings - Fork 86
feat: add lazy loading for application routes #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,41 @@ | ||
| import React from 'react' | ||
| import React, { lazy, Suspense } from 'react' | ||
| import { Routes, Route, Navigate } from 'react-router-dom' | ||
| import { AppProvider } from './context/AppContext' | ||
| import { ThemeProvider } from './context/ThemeContext' | ||
| import Navbar from './components/Navbar' | ||
| import Navbar from './components/Navbar' | ||
| import RateLimitBanner from './components/RateLimitBanner' | ||
| import HomePage from './pages/HomePage' | ||
| import OverviewPage from './pages/OverviewPage' | ||
| import RepositoriesPage from './pages/RepositoriesPage' | ||
| import ContributorsPage from './pages/ContributorsPage' | ||
| import ContributorProfilePage from './pages/ContributorProfilePage' | ||
| import NetworkPage from './pages/NetworkPage' | ||
| import AnalyticsPage from './pages/AnalyticsPage' | ||
| import GovernancePage from './pages/GovernancePage' | ||
| import SettingsPage from './pages/SettingsPage' | ||
| import Footer from './components/layout/Footer' | ||
| import Support from './pages/Support' | ||
| import { Spinner } from './components/UI' | ||
|
|
||
| // Lazy-loaded pages | ||
| const HomePage = lazy(() => import('./pages/HomePage')) | ||
| const OverviewPage = lazy(() => import('./pages/OverviewPage')) | ||
| const RepositoriesPage = lazy(() => import('./pages/RepositoriesPage')) | ||
| const ContributorsPage = lazy(() => import('./pages/ContributorsPage')) | ||
| const ContributorProfilePage = lazy(() => import('./pages/ContributorProfilePage')) | ||
| const NetworkPage = lazy(() => import('./pages/NetworkPage')) | ||
| const AnalyticsPage = lazy(() => import('./pages/AnalyticsPage')) | ||
| const GovernancePage = lazy(() => import('./pages/GovernancePage')) | ||
| const SettingsPage = lazy(() => import('./pages/SettingsPage')) | ||
| const Support = lazy(() => import('./pages/Support')) | ||
| import RequireAnalysis from './components/RequireAnalysis' | ||
|
|
||
| function Layout({ children }) { | ||
| return ( | ||
| <div style={{ minHeight: '100vh', display: 'flex', flexDirection: 'column' }}> | ||
| <div | ||
| style={{ | ||
| minHeight: '100vh', | ||
| display: 'flex', | ||
| flexDirection: 'column' | ||
| }} | ||
| > | ||
| <Navbar /> | ||
| <RateLimitBanner /> | ||
| <main style={{ flex: 1 }}>{children}</main> | ||
|
|
||
| <main style={{ flex: 1 }}> | ||
| {children} | ||
| </main> | ||
|
|
||
| <Footer /> | ||
| </div> | ||
| ) | ||
|
|
@@ -31,19 +44,42 @@ function Layout({ children }) { | |
| function AppContent() { | ||
| return ( | ||
| <Layout> | ||
| <Routes> | ||
| <Route path="/" element={<HomePage />} /> | ||
| <Route path="/overview" element={<RequireAnalysis><OverviewPage /></RequireAnalysis>} /> | ||
| <Route path="/repositories" element={<RequireAnalysis><RepositoriesPage /></RequireAnalysis>} /> | ||
| <Route path="/contributors" element={<RequireAnalysis><ContributorsPage /></RequireAnalysis>} /> | ||
| <Route path="/contributors/:username" element={<RequireAnalysis><ContributorProfilePage /></RequireAnalysis>} /> | ||
| <Route path="/network" element={<RequireAnalysis><NetworkPage /></RequireAnalysis>} /> | ||
| <Route path="/analytics" element={<RequireAnalysis><AnalyticsPage /></RequireAnalysis>} /> | ||
| <Route path="/governance" element={<RequireAnalysis><GovernancePage /></RequireAnalysis>} /> | ||
| <Route path="/settings" element={<SettingsPage />} /> | ||
| <Route path="/support-us" element={<Support />} /> | ||
| <Route path="*" element={<Navigate to="/" replace />} /> | ||
| </Routes> | ||
| <Suspense | ||
| fallback={ | ||
| <div | ||
| role="status" | ||
| aria-label="Loading page" | ||
| style={{ | ||
| minHeight: '60vh', | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| }} | ||
| > | ||
| <Spinner /> | ||
| </div> | ||
| } | ||
| > | ||
| <Routes> | ||
| <Route path="/" element={<HomePage />} /> | ||
| <Route path="/overview" element={<RequireAnalysis><OverviewPage /></RequireAnalysis>} /> | ||
| <Route path="/repositories" element={<RequireAnalysis><RepositoriesPage /></RequireAnalysis>} /> | ||
| <Route path="/contributors" element={<RequireAnalysis><ContributorsPage /></RequireAnalysis>} /> | ||
| <Route | ||
| path="/contributors/:username" | ||
| element={<RequireAnalysis><ContributorProfilePage /></RequireAnalysis>} | ||
| /> | ||
| <Route path="/network" element={<RequireAnalysis><NetworkPage /></RequireAnalysis>} /> | ||
| <Route path="/analytics" element={<RequireAnalysis><AnalyticsPage /></RequireAnalysis>} /> | ||
| <Route path="/governance" element={<RequireAnalysis><GovernancePage /></RequireAnalysis>} /> | ||
|
Comment on lines
+65
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: printf '%s\n' '--- repository conventions ---'
find /tmp/coderabbit-repo-knowledge/aossie-org-orgexplorer-226e19bd -maxdepth 2 -type f -name '*.md' -print
printf '%s\n' '--- App.jsx outline ---'
ast-grep outline src/App.jsx
printf '%s\n' '--- App.jsx relevant source ---'
sed -n '1,180p' src/App.jsxRepository: AOSSIE-Org/OrgExplorer Length of output: 4755 🏁 Script executed: printf '%s\n' '--- applicable conventions ---'
cat /tmp/coderabbit-repo-knowledge/aossie-org-orgexplorer-226e19bd/conventions/repo-wide.md
printf '%s\n' '--- Error Boundary definitions and usage ---'
rg -n -S 'ErrorBoundary|componentDidCatch|getDerivedStateFromError|React\.lazy|Suspense' --glob '!node_modules' --glob '!dist' .
printf '%s\n' '--- application entry files ---'
git ls-files | rg '(^|/)(main|index|root|App)\.(jsx?|tsx?)$'Repository: AOSSIE-Org/OrgExplorer Length of output: 5325 🏁 Script executed: printf '%s\n' '--- application bootstrap ---'
cat -n src/main.jsx
printf '%s\n' '--- package versions and scripts ---'
cat package.json
printf '%s\n' '--- root-level host markup ---'
find . -maxdepth 2 -type f \( -name '*.html' -o -name '*.jsx' -o -name '*.js' \) -not -path './node_modules/*' -printRepository: AOSSIE-Org/OrgExplorer Length of output: 1662 Add recovery for rejected lazy imports.
🤖 Prompt for AI AgentsSources: Path instructions, MCP tools |
||
| <Route path="/settings" element={<SettingsPage />} /> | ||
| <Route path="/support-us" element={<Support />} /> | ||
| <Route | ||
| path="*" | ||
| element={<Navigate to="/" replace />} | ||
| /> | ||
| </Routes> | ||
| </Suspense> | ||
| </Layout> | ||
| ) | ||
| } | ||
|
|
@@ -56,4 +92,4 @@ export default function App() { | |
| </AppProvider> | ||
| </ThemeProvider> | ||
| ) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.