From 34244157697f6a6328e3ac58ff7dd8cd16285f4f Mon Sep 17 00:00:00 2001 From: nuintun Date: Thu, 9 May 2024 20:00:16 +0800 Subject: [PATCH] feat: Update code --- app/js/components/RouteMenu/useItems.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/js/components/RouteMenu/useItems.tsx b/app/js/components/RouteMenu/useItems.tsx index 756e6007..c3bf3194 100644 --- a/app/js/components/RouteMenu/useItems.tsx +++ b/app/js/components/RouteMenu/useItems.tsx @@ -48,10 +48,10 @@ function renderLabel(item: MenuItem, selectedKeys: string[], renderItem?: Render export default function useItems(items: MenuItem[], selectedKeys: string[], renderItem?: RenderItem): Item[] { return useMemo(() => { - const result: Item[] = []; + const menuItems: Item[] = []; const itemClassName = `${prefixCls}-item`; const submenuClassName = `${prefixCls}-submenu`; - const itemsMapping: Record = {}; + const menuItemsMapping: Record = {}; for (const item of items) { const tree = new DFSTree(item, item => item.children); @@ -67,7 +67,7 @@ export default function useItems(items: MenuItem[], selectedKeys: string[], rend key, className: submenuClassName, popupClassName: submenuClassName, - children: (itemsMapping[key] = []), + children: (menuItemsMapping[key] = []), label: renderLabel(current, selectedKeys, renderItem) }; } else { @@ -79,13 +79,13 @@ export default function useItems(items: MenuItem[], selectedKeys: string[], rend } if (parent) { - itemsMapping[parent.key].push(item); + menuItemsMapping[parent.key].push(item); } else { - result.push(item); + menuItems.push(item); } } } - return result; + return menuItems; }, [selectedKeys, items, renderItem]); }