-
Hey y'all,
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
@brophdawg11, I was wondering if you would be willing to assist me. |
Beta Was this translation helpful? Give feedback.
-
const SettingsPage = lazy(() => import('../../containers/SettingsPage/SettingsPage')); or { path: routesPaths.appCatalog, Component: lazy(() => import('../../containers/AppCatalogPage/AppCatalogPage')) }, |
Beta Was this translation helpful? Give feedback.
-
helpful discussion. |
Beta Was this translation helpful? Give feedback.
-
Here's the solution I made to batch load several routes instead of getting them per component. This way I can group related pages together such as all settings pages, admin pages, etc. BatchLazy.tsximport React from 'react';
import {Outlet} from "react-router-dom";
// Do not lazy load here
import FooView from "@views/FooView.tsx";
import BarView from "@views/BarView.tsx";
const BatchLazy = () => <Outlet />
// Export them or they'll be stripped off
export {FooView, BarView}
export default BatchLazy routes.tsxconst BatchLazy = lazy(() => import('@config/routes/BatchLazy.tsx'));
// Lazy load `FooView` and `BarView` only so you can reference them in the routes
// By the time you open it they would have already been loaded by BatchLazy anyway
const FooView = lazy(() => import('@views/FooView.tsx'));
const BarView = lazy(() => import('@views/BarView.tsx'));
export const routes = (isAuth: boolean) => createBrowserRouter([
{path: '/', element: (
<Suspense fallback={'Loading...'}>
<BatchLazy />
</Suspense>
), children: [
{path: 'foo', Component: FooView},
{path: 'bar', Component: BarView},
]},
]); It works for me but I sure wish there was a build-in way to do this using v6. |
Beta Was this translation helpful? Give feedback.
const SettingsPage = lazy(() => import('../../containers/SettingsPage/SettingsPage'));
or
{ path: routesPaths.appCatalog, Component: lazy(() => import('../../containers/AppCatalogPage/AppCatalogPage')) },