For code splitting on SPA, we use dynamic import, lazy load, and
suspense and set manually
Code splitting
import React, { Suspense } from 'react';
const LazyComponent = React.lazy(()
=> import('./LazyComponent'));
const Component () => {
return (
Loading...
}>
);
};
Wrap component you want
to delay to render with lazy()
Wrap lazy component with
Suspense to show fallback
(e.g. Loading Spinner)