From 5275a203aaae46120b773f6701254155fd27efdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 13 Mar 2023 10:57:55 +0100 Subject: [PATCH] TopNav: Wrap TopSearchBar in memo to prevent unnecessary re-renders (#64667) --- public/app/core/components/AppChrome/TopSearchBar.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/core/components/AppChrome/TopSearchBar.tsx b/public/app/core/components/AppChrome/TopSearchBar.tsx index e1708f07f64..fe926adf9fb 100644 --- a/public/app/core/components/AppChrome/TopSearchBar.tsx +++ b/public/app/core/components/AppChrome/TopSearchBar.tsx @@ -19,7 +19,7 @@ import { TopSearchBarSection } from './TopBar/TopSearchBarSection'; import { TopSearchBarCommandPaletteTrigger } from './TopSearchBarCommandPaletteTrigger'; import { TOP_BAR_LEVEL_HEIGHT } from './types'; -export function TopSearchBar() { +export const TopSearchBar = React.memo(function TopSearchBar() { const styles = useStyles2(getStyles); const navIndex = useSelector((state) => state.navIndex); const location = useLocation(); @@ -67,7 +67,7 @@ export function TopSearchBar() { ); -} +}); const getStyles = (theme: GrafanaTheme2) => ({ layout: css({