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