From d0f04c7db86890bc844fef5b5cc63626180bd2d9 Mon Sep 17 00:00:00 2001 From: Oleksandr Dubenko Date: Tue, 19 Nov 2024 15:52:43 +0100 Subject: [PATCH] frontend: Memoize SidebarItem component Signed-off-by: Oleksandr Dubenko --- frontend/src/components/Sidebar/SidebarItem.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/Sidebar/SidebarItem.tsx b/frontend/src/components/Sidebar/SidebarItem.tsx index fe8df23175..ad8a8b6cac 100644 --- a/frontend/src/components/Sidebar/SidebarItem.tsx +++ b/frontend/src/components/Sidebar/SidebarItem.tsx @@ -2,7 +2,7 @@ import Collapse from '@mui/material/Collapse'; import List from '@mui/material/List'; import ListItem, { ListItemProps } from '@mui/material/ListItem'; import { useTheme } from '@mui/system'; -import React from 'react'; +import React, { memo } from 'react'; import { generatePath } from 'react-router'; import { createRouteURL, getRoute } from '../../lib/router'; import { getCluster, getClusterPrefixedPath } from '../../lib/util'; @@ -27,7 +27,7 @@ export interface SidebarItemProps extends ListItemProps, SidebarEntry { hide?: boolean; } -export default function SidebarItem(props: SidebarItemProps) { +const SidebarItem = memo((props: SidebarItemProps) => { const { label, name, @@ -248,4 +248,6 @@ export default function SidebarItem(props: SidebarItemProps) { )} ); -} +}); + +export default SidebarItem;