Skip to content

Commit

Permalink
feat: add code-splitting example
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewPattell committed Dec 14, 2023
1 parent be12f0d commit be17acc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/common/components/code-splitting/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Just a code-splitting example.
* This component will be built into a separate chunk
* @constructor
*/
const CodeSplitting = () => <div>Code-splitting in action</div>;

export default CodeSplitting;
12 changes: 11 additions & 1 deletion src/pages/not-lazy/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import { Suspense } from '@lomray/consistent-suspense';
import type { FCRoute } from '@lomray/vite-ssr-boost/interfaces/fc-route';
import { lazy } from 'react';
import { Link } from 'react-router-dom';
import Fallback from '@components/fallback';
import RouteManager from '@services/route-manager.ts';
import styles from './styles.module.scss';

const CodeSplitting = lazy(() => import('@components/code-splitting'));

/**
* Demo page with no lazy import
* @constructor
*/
const NotLazy: FCRoute = () => (
<>
<div className={styles.container}>
<p className={styles.text}>Styled text</p>
<div className={styles.text}>Styled text</div>
<div>
<Suspense fallback={<Fallback />}>
<CodeSplitting />
</Suspense>
</div>
</div>
<div className="mr20">
<Link to={RouteManager.makeURL('home')}>Go back</Link>
Expand Down
1 change: 1 addition & 0 deletions src/pages/not-lazy/styles.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.container {
display: flex;
flex-direction: column;
justify-content: center;
}

Expand Down

0 comments on commit be17acc

Please sign in to comment.