mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-23 05:59:54 +00:00
Merge pull request #6327 from thornbill/strict-mode-page
This commit is contained in:
commit
33b6106f26
@ -1,4 +1,4 @@
|
||||
import React, { type FC, type PropsWithChildren, type HTMLAttributes, useEffect, useRef } from 'react';
|
||||
import React, { type FC, type PropsWithChildren, type HTMLAttributes, useEffect, useRef, StrictMode } from 'react';
|
||||
|
||||
import viewManager from './viewManager/viewManager';
|
||||
|
||||
@ -57,6 +57,7 @@ const Page: FC<PropsWithChildren<PageProps & HTMLAttributes<HTMLDivElement>>> =
|
||||
}, [ element, isNowPlayingBarEnabled, isThemeMediaSupported ]);
|
||||
|
||||
return (
|
||||
<StrictMode>
|
||||
<div
|
||||
ref={element}
|
||||
id={id}
|
||||
@ -69,6 +70,7 @@ const Page: FC<PropsWithChildren<PageProps & HTMLAttributes<HTMLDivElement>>> =
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</StrictMode>
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
const { default: route } = await importRoute(page ?? path, type);
|
||||
|
||||
// If route is not a RouteObject, use it as the Component
|
||||
if (!route.Component) {
|
||||
return {
|
||||
element: (
|
||||
<StrictMode>
|
||||
<Page />
|
||||
</StrictMode>
|
||||
)
|
||||
Component: route
|
||||
};
|
||||
}
|
||||
|
||||
return route;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user