fix: getCurrentMenu 로직 수정
This commit is contained in:
@@ -4,10 +4,11 @@ export const getCurrentMenu = (
|
||||
menus: MenuItem[],
|
||||
pathname: string,
|
||||
): MenuItem | null => {
|
||||
return (
|
||||
menus.find((menu) => {
|
||||
if (menu.children) return getCurrentMenu(menu.children, pathname);
|
||||
return menu.urlPath === pathname;
|
||||
}) ?? null
|
||||
);
|
||||
for (const menu of menus) {
|
||||
if (menu.children) {
|
||||
return getCurrentMenu(menu.children, pathname);
|
||||
}
|
||||
if (menu.urlPath === pathname) return menu;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user