mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Restructure async route code
This commit is contained in:
parent
20c33381f9
commit
2bc3bc8a93
5 changed files with 59 additions and 41 deletions
17
src/components/AsyncPage.tsx
Normal file
17
src/components/AsyncPage.tsx
Normal file
|
@ -0,0 +1,17 @@
|
|||
import loadable from '@loadable/component';
|
||||
|
||||
interface AsyncPageProps {
|
||||
/** The relative path to the page component in the routes directory. */
|
||||
page: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Page component that uses the loadable component library to load pages defined in the routes directory asynchronously
|
||||
* with code splitting.
|
||||
*/
|
||||
const AsyncPage = loadable(
|
||||
(props: AsyncPageProps) => import(/* webpackChunkName: "[request]" */ `../routes/${props.page}`),
|
||||
{ cacheKey: (props: AsyncPageProps) => props.page }
|
||||
);
|
||||
|
||||
export default AsyncPage;
|
Loading…
Add table
Add a link
Reference in a new issue