fix: reduce app layout rerender due to router state update

This commit is contained in:
Louis 2025-09-18 18:25:57 +07:00
parent 6342956cd6
commit be83395f69

View File

@ -27,7 +27,7 @@ import {
ResizablePanel, ResizablePanel,
ResizableHandle, ResizableHandle,
} from '@/components/ui/resizable' } from '@/components/ui/resizable'
import { useCallback, useEffect } from 'react' import { useCallback, useEffect, useMemo } from 'react'
import GlobalError from '@/containers/GlobalError' import GlobalError from '@/containers/GlobalError'
import { GlobalEventHandler } from '@/providers/GlobalEventHandler' import { GlobalEventHandler } from '@/providers/GlobalEventHandler'
import ErrorDialog from '@/containers/dialogs/ErrorDialog' import ErrorDialog from '@/containers/dialogs/ErrorDialog'
@ -192,12 +192,16 @@ const LogsLayout = () => {
} }
function RootLayout() { function RootLayout() {
const router = useRouterState() const pathname = useRouterState({
select: (state) => state.location.pathname,
const isLocalAPIServerLogsRoute = })
router.location.pathname === route.localApiServerlogs || const isLocalAPIServerLogsRoute = useMemo(
router.location.pathname === route.systemMonitor || () =>
router.location.pathname === route.appLogs pathname === route.localApiServerlogs ||
pathname === route.systemMonitor ||
pathname === route.appLogs,
[pathname]
)
return ( return (
<Fragment> <Fragment>