Skip to content

Commit

Permalink
feat: Update code
Browse files Browse the repository at this point in the history
  • Loading branch information
nuintun committed May 9, 2024
1 parent 692eff3 commit 3424415
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/js/components/RouteMenu/useItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Item[]> = {};
const menuItemsMapping: Record<string, Item[]> = {};

for (const item of items) {
const tree = new DFSTree(item, item => item.children);
Expand All @@ -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 {
Expand All @@ -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]);
}

0 comments on commit 3424415

Please sign in to comment.