Skip to content

Commit c0ffd33

Browse files
authored
perf(*): Lazy load page components (#324)
1 parent fe445ce commit c0ffd33

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

src/app/components/Routes/Routes.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@ import React from 'react';
22
import { Routes as ReactRouterRoutes, Route } from 'react-router-dom';
33

44
import { ROUTES } from '../../../constants';
5-
import { AdHocView } from '../../../pages/AdHocView/AdHocView';
6-
import { ProfilesExplorerView } from '../../../pages/ProfilesExplorerView/ProfilesExplorerView';
7-
import { SettingsView } from '../../../pages/SettingsView/SettingsView';
85
import { useNavigationLinksUpdate } from './domain/useNavigationLinksUpdate';
96

7+
const ProfilesExplorerView = React.lazy(() => import('../../../pages/ProfilesExplorerView/ProfilesExplorerView'));
8+
const AdHocView = React.lazy(() => import('../../../pages/AdHocView/AdHocView'));
9+
const SettingsView = React.lazy(() => import('../../../pages/SettingsView/SettingsView'));
10+
1011
export function Routes() {
1112
useNavigationLinksUpdate();
1213

1314
return (
1415
<ReactRouterRoutes>
15-
<Route path={ROUTES.PROFILES_EXPLORER_VIEW} element={<ProfilesExplorerView />} />
16-
<Route path={ROUTES.ADHOC_VIEW} element={<AdHocView />} />
17-
<Route path={ROUTES.SETTINGS} element={<SettingsView />} />
16+
<Route path={`${ROUTES.PROFILES_EXPLORER_VIEW}/*`} element={<ProfilesExplorerView />} />
17+
<Route path={`${ROUTES.ADHOC_VIEW}/*`} element={<AdHocView />} />
18+
<Route path={`${ROUTES.SETTINGS}/*`} element={<SettingsView />} />
1819
{/* Default Route */}
1920
<Route path="/*" element={<ProfilesExplorerView />} />
2021
</ReactRouterRoutes>

src/pages/AdHocView/AdHocView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33

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

6-
export function AdHocView() {
6+
export default function AdHocView() {
77
return (
88
<>
99
<PageTitle title="Ad hoc view" />

src/pages/ProfilesExplorerView/ProfilesExplorerView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useMemo } from 'react';
22

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

5-
export function ProfilesExplorerView() {
5+
export default function ProfilesExplorerView() {
66
const sceneProfilesExplorer = useMemo(() => new SceneProfilesExplorer(), []);
77

88
return <sceneProfilesExplorer.Component model={sceneProfilesExplorer} />;

src/pages/SettingsView/SettingsView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import React from 'react';
77

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

10-
export function SettingsView() {
10+
export default function SettingsView() {
1111
const styles = useStyles2(getStyles);
1212
const { data, actions } = useSettingsView();
1313

0 commit comments

Comments
 (0)