Skip to content

Commit

Permalink
Add logic to prevent error when looking up block context
Browse files Browse the repository at this point in the history
We can only look up a block's context if 'blockType' is true. This commit therefore adds a check to ensure 'blockType' is true before creating a context object.
  • Loading branch information
Siobhan committed Oct 11, 2021
1 parent 29f4043 commit 5a7d414
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ function UncontrolledInnerBlocks( props ) {
// Wrap context provider if (and only if) block has context to provide.
const blockType = getBlockType( block.name );

const blockProvidesContext = {
const blockProvidesContext = blockType && {
...blockType.providesContext,
...blockType.providesNativeInnerBlockContext,
};

if ( blockType && blockProvidesContext ) {
if ( blockProvidesContext ) {
const context = getBlockContext( block.attributes, blockType );

blockList = (
Expand Down

0 comments on commit 5a7d414

Please sign in to comment.