Skip to content

Commit

Permalink
Exit early
Browse files Browse the repository at this point in the history
  • Loading branch information
david-szabo97 committed Nov 12, 2020
1 parent ee50757 commit 2bc91ab
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/components/src/navigation/use-create-navigation-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,23 @@ export const useCreateNavigationTree = () => {
visited.push( current.menu );
queue = [ ...queue, ...getChildMenu( current.menu ) ];

callback( current );
if ( callback( current ) === false ) {
break;
}
}
};

const isMenuEmpty = ( menuToCheck ) => {
let count = 0;
let isEmpty = true;

traverseMenu( menuToCheck, ( current ) => {
if ( ! current.isEmpty ) {
count++;
isEmpty = false;
return false;
}
} );

return count === 0;
return isEmpty;
};

return {
Expand Down

0 comments on commit 2bc91ab

Please sign in to comment.