From 9f3f45c52419a43e66f3a5b01e7d86f501fc5ce7 Mon Sep 17 00:00:00 2001 From: Saurabhsing21 Date: Thu, 16 Jan 2025 17:15:23 +0530 Subject: [PATCH] -fixed formate issue Signed-off-by: Saurabhsing21 --- src/App.tsx | 84 ++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 93710361..e4771185 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,81 +1,81 @@ -import { ComponentType, Suspense, lazy, useEffect } from "react"; // Added `useEffect` for handling skeleton cleanup -import { Toaster } from "@/components/ui/toaster"; -import { Route, Switch } from "wouter"; -import "./components/CmdKMenu"; -import { ContextProviders } from "./ContextProviders"; -import React from "react"; +import { ComponentType, Suspense, lazy, useEffect } from "react" // Added `useEffect` for handling skeleton cleanup +import { Toaster } from "@/components/ui/toaster" +import { Route, Switch } from "wouter" +import "./components/CmdKMenu" +import { ContextProviders } from "./ContextProviders" +import React from "react" // Lazy loading helper const lazyImport = (importFn: () => Promise) => lazy>(async () => { try { - const module = await importFn(); + const module = await importFn() if (module.default) { - return { default: module.default }; + return { default: module.default } } - const pageExportNames = ["Page", "Component", "View"]; + const pageExportNames = ["Page", "Component", "View"] for (const suffix of pageExportNames) { - const keys = Object.keys(module).filter((key) => key.endsWith(suffix)); + const keys = Object.keys(module).filter((key) => key.endsWith(suffix)) if (keys.length > 0) { - return { default: module[keys[0]] }; + return { default: module[keys[0]] } } } const componentExport = Object.values(module).find( (exp) => typeof exp === "function" && exp.prototype?.isReactComponent - ); + ) if (componentExport) { - return { default: componentExport }; + return { default: componentExport } } throw new Error( `No valid React component found in module. Available exports: ${Object.keys(module).join(", ")}` - ); + ) } catch (error) { - console.error("Failed to load component:", error); - throw error; + console.error("Failed to load component:", error) + throw error } - }); + }) // Lazy-loaded pages -const AiPage = lazyImport(() => import("@/pages/ai")); -const AuthenticatePage = lazyImport(() => import("@/pages/authorize")); -const DashboardPage = lazyImport(() => import("@/pages/dashboard")); +const AiPage = lazyImport(() => import("@/pages/ai")) +const AuthenticatePage = lazyImport(() => import("@/pages/authorize")) +const DashboardPage = lazyImport(() => import("@/pages/dashboard")) const EditorPage = lazyImport(async () => { const [editorModule] = await Promise.all([ import("@/pages/editor"), import("@/lib/utils/load-prettier").then((m) => m.loadPrettier()), - ]); + ]) return editorModule; -}); -const LandingPage = lazyImport(() => import("@/pages/landing")); -const MyOrdersPage = lazyImport(() => import("@/pages/my-orders")); -const NewestPage = lazyImport(() => import("@/pages/newest")); -const PreviewPage = lazyImport(() => import("@/pages/preview")); -const QuickstartPage = lazyImport(() => import("@/pages/quickstart")); -const SearchPage = lazyImport(() => import("@/pages/search")); -const SettingsPage = lazyImport(() => import("@/pages/settings")); -const UserProfilePage = lazyImport(() => import("@/pages/user-profile")); -const ViewOrderPage = lazyImport(() => import("@/pages/view-order")); -const ViewSnippetPage = lazyImport(() => import("@/pages/view-snippet")); -const DevLoginPage = lazyImport(() => import("@/pages/dev-login")); +}) +const LandingPage = lazyImport(() => import("@/pages/landing")) +const MyOrdersPage = lazyImport(() => import("@/pages/my-orders")) +const NewestPage = lazyImport(() => import("@/pages/newest")) +const PreviewPage = lazyImport(() => import("@/pages/preview")) +const QuickstartPage = lazyImport(() => import("@/pages/quickstart")) +const SearchPage = lazyImport(() => import("@/pages/search")) +const SettingsPage = lazyImport(() => import("@/pages/settings")) +const UserProfilePage = lazyImport(() => import("@/pages/user-profile")) +const ViewOrderPage = lazyImport(() => import("@/pages/view-order")) +const ViewSnippetPage = lazyImport(() => import("@/pages/view-snippet")) +const DevLoginPage = lazyImport(() => import("@/pages/dev-login")) class ErrorBoundary extends React.Component< { children: React.ReactNode }, { hasError: boolean } > { constructor(props: { children: React.ReactNode }) { - super(props); + super(props) this.state = { hasError: false }; } static getDerivedStateFromError() { - return { hasError: true }; + return { hasError: true } } render() { if (this.state.hasError) { - return
Something went wrong loading the page.
; + return
Something went wrong loading the page.
} - return this.props.children; + return this.props.children } } @@ -83,11 +83,11 @@ function App() { // Added useEffect to handle cleanup of the skeleton loader useEffect(() => { // Hide the skeleton from index.html when React mounts - const skeletonLoader = document.getElementById("skeleton-loader"); + const skeletonLoader = document.getElementById("skeleton-loader") if (skeletonLoader) { - skeletonLoader.style.display = "none"; // Hides the skeleton after the React app is ready + skeletonLoader.style.display = "none"// Hides the skeleton after the React app is ready } - }, []); + }, []) return ( @@ -114,7 +114,7 @@ function App() { - ); + ) } -export default App; +export default App