Merge pull request #6327 from thornbill/strict-mode-page

This commit is contained in:
Bill Thornton 2024-11-18 23:02:26 -05:00 committed by GitHub
commit 33b6106f26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 23 deletions

View File

@ -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>
);
};

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;
}
};
};