From 22a699b673198846ab2b838d853d7bbc2e61225c Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Mon, 17 Jun 2024 17:30:21 +0800 Subject: [PATCH] Fix re-rendering bug --- .../src/components/sidebar/Sidebar.tsx | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/code/ui/manager/src/components/sidebar/Sidebar.tsx b/code/ui/manager/src/components/sidebar/Sidebar.tsx index c4c1b35db9ce..5b6513d43269 100644 --- a/code/ui/manager/src/components/sidebar/Sidebar.tsx +++ b/code/ui/manager/src/components/sidebar/Sidebar.tsx @@ -103,6 +103,17 @@ const useCombination = ( return useMemo(() => ({ hash, entries: Object.entries(hash) }), [hash]); }; +const updateQueryParams = (params: Record) => { + const url = new URL(window.location.href); + Object.entries(params).forEach(([key, value]) => { + if (value) { + url.searchParams.set(key, value); + } else { + url.searchParams.delete(key); + } + }); + window.history.pushState({}, '', url); +}; export interface SidebarProps extends API_LoadedRefData { refs: State['refs']; status: State['status']; @@ -152,23 +163,7 @@ export const Sidebar = React.memo(function Sidebar({ isLoading={isLoading} onMenuClick={onMenuClick} /> - {index && ( - { - const url = new URL(window.location.href); - Object.entries(params).forEach(([key, value]) => { - if (value) { - url.searchParams.set(key, value); - } else { - url.searchParams.delete(key); - } - }); - window.history.pushState({}, '', url); - }} - /> - )} + {index && }