fix: avoid the entire app layout re render on route change
This commit is contained in:
parent
be83395f69
commit
5f6a68d844
@ -192,17 +192,16 @@ const LogsLayout = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function RootLayout() {
|
function RootLayout() {
|
||||||
const pathname = useRouterState({
|
const getInitialLayoutType = () => {
|
||||||
select: (state) => state.location.pathname,
|
const pathname = window.location.pathname
|
||||||
})
|
return (
|
||||||
const isLocalAPIServerLogsRoute = useMemo(
|
|
||||||
() =>
|
|
||||||
pathname === route.localApiServerlogs ||
|
pathname === route.localApiServerlogs ||
|
||||||
pathname === route.systemMonitor ||
|
pathname === route.systemMonitor ||
|
||||||
pathname === route.appLogs,
|
pathname === route.appLogs
|
||||||
[pathname]
|
)
|
||||||
)
|
}
|
||||||
|
|
||||||
|
const IS_LOGS_ROUTE = getInitialLayoutType()
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<ServiceHubProvider>
|
<ServiceHubProvider>
|
||||||
@ -214,7 +213,7 @@ function RootLayout() {
|
|||||||
<AuthProvider>
|
<AuthProvider>
|
||||||
<DataProvider />
|
<DataProvider />
|
||||||
<GlobalEventHandler />
|
<GlobalEventHandler />
|
||||||
{isLocalAPIServerLogsRoute ? <LogsLayout /> : <AppLayout />}
|
{IS_LOGS_ROUTE ? <LogsLayout /> : <AppLayout />}
|
||||||
</AuthProvider>
|
</AuthProvider>
|
||||||
</ExtensionProvider>
|
</ExtensionProvider>
|
||||||
{/* {isLocalAPIServerLogsRoute ? <LogsLayout /> : <AppLayout />} */}
|
{/* {isLocalAPIServerLogsRoute ? <LogsLayout /> : <AppLayout />} */}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user