Skip to content

Commit

Permalink
Rename directSubMenus to childMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
david-szabo97 committed Nov 4, 2020
1 parent cdc443d commit 0de18a3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/components/src/navigation/use-create-navigation-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export const useCreateNavigationTree = () => {
* Key is the menu prop of the menu
* Value is an array of menu keys
*/
const [ directSubMenus, setDirectSubMenus ] = useState( {} );
const getDirectSubMenus = ( menu ) => directSubMenus[ menu ] || [];
const [ childMenu, setChildMenu ] = useState( {} );
const getChildMenu = ( menu ) => childMenu[ menu ] || [];

const traverseMenu = ( startMenu, callback ) => {
const visited = [];
Expand All @@ -46,7 +46,7 @@ export const useCreateNavigationTree = () => {
}

visited.push( current.menu );
queue = [ ...queue, ...getDirectSubMenus( current.menu ) ];
queue = [ ...queue, ...getChildMenu( current.menu ) ];

callback( current );
}
Expand All @@ -73,7 +73,7 @@ export const useCreateNavigationTree = () => {
menus,
getMenu,
addMenu: ( key, value ) => {
setDirectSubMenus( ( state ) => {
setChildMenu( ( state ) => {
const newState = { ...state };

if ( ! newState[ value.parentMenu ] ) {
Expand All @@ -88,7 +88,7 @@ export const useCreateNavigationTree = () => {
addMenu( key, value );
},
removeMenu,
directSubMenus,
directSubMenus: childMenu,
traverseMenu,
isMenuEmpty,
};
Expand Down

0 comments on commit 0de18a3

Please sign in to comment.