1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Move strict mode to page component

This commit is contained in:
Bill Thornton 2024-11-18 16:55:45 -05:00
parent a077acb7c8
commit e71d83af94
2 changed files with 26 additions and 23 deletions

View file

@ -1,4 +1,3 @@
import React, { StrictMode } from 'react';
import type { RouteObject } from 'react-router-dom';
export enum AsyncRouteType {
@ -19,7 +18,7 @@ export interface AsyncRoute {
type?: AsyncRouteType
}
const importPage = (page: string, type: AsyncRouteType) => {
const importRoute = (page: string, type: AsyncRouteType) => {
switch (type) {
case AsyncRouteType.Dashboard:
return import(/* webpackChunkName: "[request]" */ `../../apps/dashboard/routes/${page}`);
@ -38,14 +37,16 @@ export const toAsyncPageRoute = ({
return {
path,
lazy: async () => {
const { default: Page } = await importPage(page ?? path, type);
return {
element: (
<StrictMode>
<Page />
</StrictMode>
)
};
const { default: route } = await importRoute(page ?? path, type);
// If route is not a RouteObject, use it as the Component
if (!route.Component) {
return {
Component: route
};
}
return route;
}
};
};