Skip to content

Commit

Permalink
Columns: Avoid re-render and subsequent action dispatch by adopting m…
Browse files Browse the repository at this point in the history
…odule constant (#7720)

We were passing a new allowedBlocks reference on each column render. This dispatch additional unnecessary further actions to update inner block settings.
allowedBlocks reference should only be changed if, in fact, we are changing the allowedBlocks.
In the columns block, we can make allowed block a constant given that it never changes.

This problem may cause noticeable lag when writing/using columns because updating the InnerBlock setting may cause another rerender and another rerender updates the settings again. So this change prevents cascade re-renders.
  • Loading branch information
jorgefilipecosta authored Jul 5, 2018
1 parent 06a621d commit 622bbfb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core-blocks/columns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
import './style.scss';
import './editor.scss';

const ALLOWED_BLOCKS = [ 'core/column' ];

/**
* Returns the layouts configuration for a given number of columns.
*
Expand Down Expand Up @@ -145,7 +147,7 @@ export const settings = {
<InnerBlocks
template={ getColumnsTemplate( columns ) }
templateLock="all"
allowedBlocks={ [ 'core/column' ] } />
allowedBlocks={ ALLOWED_BLOCKS } />
</div>
</Fragment>
);
Expand Down

0 comments on commit 622bbfb

Please sign in to comment.