Skip to content

Commit

Permalink
Navigation Block: Avoid creating a new array/object on every render (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan authored Apr 1, 2021
1 parent 28893c2 commit 7b22e5f
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions packages/block-library/src/navigation/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ import useBlockNavigator from './use-block-navigator';
import NavigationPlaceholder from './placeholder';
import PlaceholderPreview from './placeholder-preview';

const ALLOWED_BLOCKS = [
'core/navigation-link',
'core/search',
'core/social-links',
'core/page-list',
'core/spacer',
];

const LAYOUT = {
type: 'default',
alignments: [],
};

function Navigation( {
selectedBlockHasDescendants,
attributes,
Expand Down Expand Up @@ -64,13 +77,7 @@ function Navigation( {
className: 'wp-block-navigation__container',
},
{
allowedBlocks: [
'core/navigation-link',
'core/search',
'core/social-links',
'core/page-list',
'core/spacer',
],
allowedBlocks: ALLOWED_BLOCKS,
orientation: attributes.orientation || 'horizontal',
renderAppender:
( isImmediateParentOfSelectedBlock &&
Expand All @@ -84,10 +91,7 @@ function Navigation( {
// Block on the experimental menus screen does not
// inherit templateLock={ 'all' }.
templateLock: false,
__experimentalLayout: {
type: 'default',
alignments: [],
},
__experimentalLayout: LAYOUT,
placeholder: <PlaceholderPreview />,
}
);
Expand Down

0 comments on commit 7b22e5f

Please sign in to comment.