Skip to content

Commit

Permalink
perf(*): Lazy load page components (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
grafakus authored Jan 20, 2025
1 parent fe445ce commit c0ffd33
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/app/components/Routes/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ import React from 'react';
import { Routes as ReactRouterRoutes, Route } from 'react-router-dom';

import { ROUTES } from '../../../constants';
import { AdHocView } from '../../../pages/AdHocView/AdHocView';
import { ProfilesExplorerView } from '../../../pages/ProfilesExplorerView/ProfilesExplorerView';
import { SettingsView } from '../../../pages/SettingsView/SettingsView';
import { useNavigationLinksUpdate } from './domain/useNavigationLinksUpdate';

const ProfilesExplorerView = React.lazy(() => import('../../../pages/ProfilesExplorerView/ProfilesExplorerView'));
const AdHocView = React.lazy(() => import('../../../pages/AdHocView/AdHocView'));
const SettingsView = React.lazy(() => import('../../../pages/SettingsView/SettingsView'));

export function Routes() {
useNavigationLinksUpdate();

return (
<ReactRouterRoutes>
<Route path={ROUTES.PROFILES_EXPLORER_VIEW} element={<ProfilesExplorerView />} />
<Route path={ROUTES.ADHOC_VIEW} element={<AdHocView />} />
<Route path={ROUTES.SETTINGS} element={<SettingsView />} />
<Route path={`${ROUTES.PROFILES_EXPLORER_VIEW}/*`} element={<ProfilesExplorerView />} />
<Route path={`${ROUTES.ADHOC_VIEW}/*`} element={<AdHocView />} />
<Route path={`${ROUTES.SETTINGS}/*`} element={<SettingsView />} />
{/* Default Route */}
<Route path="/*" element={<ProfilesExplorerView />} />
</ReactRouterRoutes>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/AdHocView/AdHocView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';

import { AdHocTabs } from './ui/AdHocTabs';

export function AdHocView() {
export default function AdHocView() {
return (
<>
<PageTitle title="Ad hoc view" />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ProfilesExplorerView/ProfilesExplorerView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useMemo } from 'react';

import { SceneProfilesExplorer } from './components/SceneProfilesExplorer/SceneProfilesExplorer';

export function ProfilesExplorerView() {
export default function ProfilesExplorerView() {
const sceneProfilesExplorer = useMemo(() => new SceneProfilesExplorer(), []);

return <sceneProfilesExplorer.Component model={sceneProfilesExplorer} />;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/SettingsView/SettingsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React from 'react';

import { useSettingsView } from './domain/useSettingsView';

export function SettingsView() {
export default function SettingsView() {
const styles = useStyles2(getStyles);
const { data, actions } = useSettingsView();

Expand Down

0 comments on commit c0ffd33

Please sign in to comment.