From 94634a319895532098beb59e83ee778f0d5701fb Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 3 Sep 2026 08:29:05 +0530 Subject: [PATCH 1/3] feat(routes): implement code splitting and lazy loading for application pages Closes #140 Replaces static page imports in App.jsx with React.lazy dynamic imports. Wraps the route definitions in a Suspense boundary with an accessible Spinner fallback loader and an ErrorBoundary to gracefully handle route loading failures. --- src/App.jsx | 94 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 25 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 56d854d..b552dd0 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,21 +1,61 @@ -import React from 'react' +import React, { Suspense, Component } 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 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 Footer from './components/layout/Footer' import RequireAnalysis from './components/RequireAnalysis' +import { Spinner } from './components/UI' + +const HomePage = React.lazy(() => import('./pages/HomePage')) +const OverviewPage = React.lazy(() => import('./pages/OverviewPage')) +const RepositoriesPage = React.lazy(() => import('./pages/RepositoriesPage')) +const ContributorsPage = React.lazy(() => import('./pages/ContributorsPage')) +const ContributorProfilePage = React.lazy(() => import('./pages/ContributorProfilePage')) +const NetworkPage = React.lazy(() => import('./pages/NetworkPage')) +const AnalyticsPage = React.lazy(() => import('./pages/AnalyticsPage')) +const GovernancePage = React.lazy(() => import('./pages/GovernancePage')) +const SettingsPage = React.lazy(() => import('./pages/SettingsPage')) +const Support = React.lazy(() => import('./pages/Support')) + +class ErrorBoundary extends Component { + constructor(props) { + super(props) + this.state = { hasError: false } + } + + static getDerivedStateFromError() { + return { hasError: true } + } + + componentDidCatch(error, errorInfo) { + console.error('Route load error:', error, errorInfo) + } + + render() { + if (this.state.hasError) { + return ( +
+

Unable to load page

+

A network error occurred while loading this section.

+ +
+ ) + } + return this.props.children + } +} + +function PageLoader() { + return ( +
+ +
+ ) +} function Layout({ children }) { return ( @@ -31,19 +71,23 @@ function Layout({ children }) { function AppContent() { return ( - - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - + + }> + + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + + ) } From 78ea7e2664a59639109f0845d8ec19c8856d800d Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 3 Sep 2026 19:18:03 +0530 Subject: [PATCH 2/3] fix(app): update ErrorBoundary fallback message to generic error wording --- src/App.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.jsx b/src/App.jsx index b552dd0..a41789b 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -38,7 +38,7 @@ class ErrorBoundary extends Component { return (

Unable to load page

-

A network error occurred while loading this section.

+

An error occurred while loading this page.

From a53bb0d1090f2eeebc5a786edda8cd9fa09e2602 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 3 Sep 2026 19:25:43 +0530 Subject: [PATCH 3/3] refactor(app): externalize loading and error strings into ROUTE_STRINGS resource object --- src/App.jsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index a41789b..cb99769 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -17,7 +17,12 @@ const NetworkPage = React.lazy(() => import('./pages/NetworkPage')) const AnalyticsPage = React.lazy(() => import('./pages/AnalyticsPage')) const GovernancePage = React.lazy(() => import('./pages/GovernancePage')) const SettingsPage = React.lazy(() => import('./pages/SettingsPage')) -const Support = React.lazy(() => import('./pages/Support')) +const ROUTE_STRINGS = { + ERROR_TITLE: 'Unable to load page', + ERROR_MESSAGE: 'An error occurred while loading this page.', + RELOAD_BUTTON: 'Reload Page', + LOADING_LABEL: 'Loading page', +} class ErrorBoundary extends Component { constructor(props) { @@ -37,10 +42,10 @@ class ErrorBoundary extends Component { if (this.state.hasError) { return (
-

Unable to load page

-

An error occurred while loading this page.

+

{ROUTE_STRINGS.ERROR_TITLE}

+

{ROUTE_STRINGS.ERROR_MESSAGE}

) @@ -51,7 +56,7 @@ class ErrorBoundary extends Component { function PageLoader() { return ( -
+
)