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,18 +57,20 @@ const Page: FC<PropsWithChildren<PageProps & HTMLAttributes<HTMLDivElement>>> =
|
||||
}, [ element, isNowPlayingBarEnabled, isThemeMediaSupported ]);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={element}
|
||||
id={id}
|
||||
data-role='page'
|
||||
className={`page ${className}`}
|
||||
data-title={title}
|
||||
data-backbutton={isBackButtonEnabled}
|
||||
data-menubutton={isMenuButtonEnabled}
|
||||
data-backdroptype={backDropType}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
<StrictMode>
|
||||
<div
|
||||
ref={element}
|
||||
id={id}
|
||||
data-role='page'
|
||||
className={`page ${className}`}
|
||||
data-title={title}
|
||||
data-backbutton={isBackButtonEnabled}
|
||||
data-menubutton={isMenuButtonEnabled}
|
||||
data-backdroptype={backDropType}
|
||||
>
|
||||
{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);
|
||||
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;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user